2016年1月3日日曜日

WindowsでVagrantのインストールから起動までのメモ

まずはVagrantをインストール

Vagrantのダウンロードページからmsiファイルを選択してインストール

以下のように動作確認できればOK.

 
> vagrant --version
Vagrant 1.8.1

BOXのダウンロード

vagrantboxのサンプル配布サイトからboxファイルを探す。今回はCentOS6.3 の64bit版を使用する。

 
> vagrant box add Centosh63_x64 https://s3.amazonaws.com/itmat-public/centos-6.3-chef-1
0.14.2.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'Centos63_x64' (v0) for provider:
    box: Downloading: https://s3.amazonaws.com/itmat-public/centos-6.3-chef-10.14.2.box
    box:
==> box: Successfully added box 'Centos63_x64' (v0) for 'virtualbox'!

> vagrant box list
Centos63_x64 (virtualbox, 0)
 
> rvagrant init Centos63_x64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

Vagrantfileを編集して、以下の内容をコメントアウト
config.vm.network :private_network, ip: "192.168.33.10"


vagrant up を実行すればVMが立ち上がる。
 
> vagrant up


ちなみに、Virtual Boxのバージョンが4.2.0のときは、以下のエラーが出て起動できなかった。
Virtual Boxのバージョンを上げて解決。
 
Stderr: VBoxManage.exe: error: Shared folder named 'vagrant' already exists
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_IN_USE (0x80bb000c), component SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "CreateSharedFolder(Bstr(name).raw(), Bstr(hostpath).raw(), fWritable, fAutoMount)" at line 978 of file VBoxManageMisc.cpp