VagrantでVirtualboxの仮想マシンを作成 on Windows

Vagrant1.1がリリースされてVirtualbox以外の仮想マシンの操作もできるようになり
Rubygemsでの提供ではなくバイナリパッケージでの提供になった。

読み方はベイグラント?ということは

Vagrantfile

Vagrant.configure("2") do |config|
# ...略
end

突然現れた「2」がよくわからなかったがドキュメントに記載があった。

Currently, there are only two supported versions: "1" and "2". Version 1 represents the configuration from Vagrant 1.0.x. "2" represents the configuration for 1.1+ leading up to 2.0.x.

http://docs.vagrantup.com/v2/vagrantfile/version.html

1.0と1.1ではVagrantfileでの設定方法が変わったようで1.0系のを使いたい場合は「1」。1.1+2.0.xでの設定方法を使うには「2」と記載する様子。


とりあえず試しでWindowsにインストールして仮想マシンの起動までやった。

Install

上記URLからバイナリパッケージをダウンロードして来て起動してインストーラにしたがってインストールした。

デフォルトのインストールPATH

C:\vagrant\vagrant

vagrantコマンドを使って操作していくのでbin/にPATHを通しておくことにした。

仮想マシンの作成

仮想マシンの雛形としてboxが用意されているので基本的には公開されているboxを利用して仮想マシンを作成すればよさそう。

今回はCentOS6.4 x86_64をインストールすることにした。

vagrant box add centos_6_4 http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130309.box
vagrant init centos_6_4 # カレントディレクトリにVagrantfileが作成される
vagrant up # 仮想マシンの起動
vagrant ssh # sshで仮想マシンに接続なのだけど

windowsにsshコマンドなんざ入れていないのでこんな感じにエラーる。

`ssh` executable not found in any directories in the %PATH% variable. Is an
SSH client installed? Try installing Cygwin, MinGW or Git, all of which
contain an SSH client. Or use the PuTTY SSH client with the following
authentication information shown below:

ログインに必要な情報を表示してくれるのでPuTTY等のsshクライアントで接続する。
表示されていないがvagrantユーザのパスワードはユーザ名と同じである。

Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/username/.vagrant.d/insecure_private_key

Virtualbox側には「bin_10桁の数字」みたいな仮想マシン名で登録されていた。
とりあえず動かすまではできたので複数マシン起動やVagrantfileの設定を調べる。