過去ログ

アフィリエイト広告を利用しています

CentOS 6.3 i386をVagrantを使い再現可能な開発環境を構築

作成環境

VirtualBox-4.2.6セットアップ

RVMのインストール

 bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

 vi ~/.bash_profile
 [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

 source ~/.bash_profile

 rvm install 1.9.3
 rvm use 1.9.3
 rvm --default 1.9.3

Vagrantのインストール

 gem install vagrant

Bundlerのインストール

 gem install bundler

VeeWeeのインストール

 git clone git://github.com/jedi4ever/veewee.git

 vi veewee/.rvmrc
 1.9.2 となっている部分を 1.9.3
 
 cd veewee
 bundle install

仮想マシンの作成

  • テンプレートを探す
 vagrant basebox templates
  • テンプレート生成
 bundle exec vagrant basebox define centos_63_i386 CentOS-6.3-i386-minimal
  • isoのダウンロード先書き換え
 vi definitions/centos_63_i386/definition.rb
 :iso_src => "ftp://ftp.riken.jp/Linux/centos/6.3/isos/i386/CentOS-6.3-i386-minimal.iso",
  • インストール設定変更(環境によって替える)
 vi definitions/centos_63_i386/ks.cfg
 lang ja_JP.UTF-8
 keyboard jp106
 timezone Asia/Tokyo
  • ビルド
 vagrant basebox build  centos_63_i386
 >Download? (Yes/No)
 ISOファイルをダウンロードするか確認されるのでYesと答える

 ビルドが完了して、仮想マシンが立ち上がるまで待つ
  • 接続テスト
 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 7222 -l vagrant 127.0.0.1
 パスワードは「definitions/centos_63_i386/definition.rb」の「ssh_password」に書かれている(ssh_userがユーザー名)
 
 [vagrant@localhost ~]$
 と表示されれば成功
  • boxファイルへエクスポート
 vagrant basebox export centos_63_i386
 生成されたboxファイルは適当な場所におく

仮想環境登録とテスト(この辺は曖昧。。。)

 vagrant box add 'centos_63_i386' '/xxxxx/Development/box/centos_63_i386.box'
 vagrant init centos_63_i386
  • 仮想環境の起動
 vagrant up
  • 起動したらsshで接続できるか確認する
 vagrant ssh
 「/vagrant 」に起動した場所がマウントされる
 vagrant halt
  • 作業情報の破棄
 vagrant destroy