bizevo-provisioningの環境構築

プロビジョニングのリポジトリをクローンする

$ git clone https://github.com/wata-gh/bizevo-provisioning.git

vagrantをインストールするためにcaskをインストールする

$ brew install caskroom/cask/brew-cask

vagrantのインストール

$ brew install caskroom/cask/brew-cask

VirtualBox のインストール

$ brew cask install virtualbox

vagrant起動

$ vagrant up
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:

mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant

The error output from the last command was:

/sbin/mount.vboxsf: mounting failed with the error: No such device

vagrant-vbguestプラグインのインストール

$ vagrant plugin install vagrant-vbguest

berkshelfのインストール

$ gem install berkshelf

さきほどupしたものを削除する

$ vagrant box list
bizevo/centos7_64 (virtualbox, 0)
$ vagrant box remove bizevo/centos7_64

再びvagrant up

$ vagrant up
Complete!
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 4.3.18 - guest version is 4.3.14
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.18 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.3.14 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox non-DKMS kernel modules[  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module[  OK  ]
Building the shared folder support module[  OK  ]
Building the OpenGL support module[  OK  ]
Doing non-kernel setup of the Guest Additions[  OK  ]
Starting the VirtualBox Guest Additions [  OK  ]
Installing the Window System drivers
Could not find the X.Org or XFree86 Window System, skipping.
An error occurred during installation of VirtualBox Guest Additions 4.3.18. Some functionality may not work as intended.
In most cases it is OK that the "Window System drivers" installation failed.
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/keiwt/bizevo-provisioning
  • Could not find the X.Org or XFree86 Window System, skipping.!!!!!!!!!!!!!! こちらはguiをfalseにすれば直るようです。
    しかし、virtualboxguiを使うことは恐らくないと思います。

  • An error occurred during installation of VirtualBox Guest Additions 4.3.18. Some functionality may not work as intended. こちらは以下のコマンドで直ります。
    GuestAdditions 4.3.18 running --- OK.
    となればよいです。

$ sudo ln -s /opt/VBoxGuestAdditions-4.3.14/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions

ssh の設定

  • ディレクトリの作成
$ mkdir ~/.ssh
  • ssh設定の追記
$ vagrant ssh-config --host bizevo >> ~/.ssh/config

bizevoにアクセス

$ ssh bizevo

VMに接続できた場合

[vagrant@localhost ~]$ pwd
/home/vagrant

あくまで、sshの設定がうまくいったか確認するためだったので、VMから抜ける

[vagrant@localhost ~]$ logout

chef をインストール

$ gem install chef

chef-soloをknife-soloで実行できるようにする

$ gem install knife-solo

bizevoに対してchef-soloをインストール

$ knife solo prepare bizevo

※以下のログが表示される場合は ~/.profileに
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
としてから再度実行してみてください。

Bootstrapping Chef...
ERROR: SyntaxError: (eval):1: syntax error, unexpected tSYMBEG, expecting end-of-input
...straps::/etc/profile.d/lang.sh:line19:warning:setlocale:LC_C...
...                               ^

プロビジョニングの実行

 knife solo cook vagrant@bizevo

sshが失敗する場合は以下の手順を試してみてください。

ploading the kitchen...
ssh: Could not resolve hostname bizevo: nodename nor servname provided, or not known
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [sender=2.6.9]
ERROR: RuntimeError: Failed to launch command ["rsync", "-rL", "--rsh=ssh vagrant@bizevo", "--delete-after", "--exclude=revision-deploys", "--exclude=tmp", "--exclude=.git", "--exclude=.hg", "--exclude=.svn", "--exclude=.bzr", "/Library/Ruby/Gems/2.0.0/gems/knife-solo-0.4.2/lib/knife-solo/resources/patch_cookbooks/", ":~/chef-solo/cookbooks-1"]

sshの設定(root用)

$ sudo mkdir /var/root/.ssh
$ sudo cp ~/.ssh/config /var/root/.ssh/config

プロビジョニングの実行

$ sudo knife solo cook bizevo

完了!!!!!!!