vargrant用のOSイメージを用いて
スクリプトで指定したHW構成にてCUIより仮想環境を立ち上げる。
環境は下記の通り。
Max OS X 10.7.5
gem 1.3.6
ruby 1.8.7
事前作業
Virtual Boxのダウンロードとセットアップ
本作業
vagrantの導入
# gem install vagrant
# イメージのURLは vagrantbox.es を参照のこと
% vagrant box add centos5.8_x86_64 http://tag1consulting.com/files/centos-5.8-x86-64-minimal.box
% vagrant init centos5.8_x86_64
#; 作業ディレクトリに Vagrantfile が作成される。こいつが仮想環境の設定ファイル
ホストとの接続Ethを作る
VMのIPを192.168.1.50にする。
下記の用にVagrantfileを編集する。
```
Vagrant::Config.run do |config|
# 中略...
# ↓が追記
config.vm.base_mac = "080027F7F048"
config.vm.customize ["modifyvm", :id, "--memory", 1024]
config.vm.network :hostonly, "192.168.50.2", :netmask => "255.255.255.0"
# 中略...
end
# ↓も追記
include_vagrantfile = File.expand_path("../include/Vagrantfile", __FILE_)
load include_vagrantfile if File.exist?(include_vagrantfile)
```
基本的な操作
Vagrantfileの配置されたディレクトリで下記を実行。
``` 仮想環境の起動停止処理
仮想環境立ち上げ
% vagrant up
仮想環境シャットダウン
% vagrant halt
```
※ ホスト側のVagrantfileが存在するディレクトリは、仮想側の/vagrantにマウントされている
Sahara https://github.com/jedi4ever/sahara
Saharaはvagrantで上げるインスタンスの変更について rollback - commitを可能にする
% vagrant gem install sahara
% vagrant sandbox on # saharaによる管理開始
% vagrant sandbox rollback # ここまでの変更を on 時まで戻す
% vagrant sandbox commit # ここまでの変更をcommitする
参考サイト
http://www.ryuzee.com/contents/blog/4292
http://kazuph.hateblo.jp/entry/2013/02/05/234243