Test Kitchen Windows でテストしよう Vagrantでね
はい。僕です。
最近、WindowsでChefってできるのかな、と思い、Test Kitchenしてみたので、共有します。
ほぼ、こちらのサイトを参考にしています↓
pinter.org
Test KitchenをWindowsに対してVagrantで行う準備
vagrant plugin install vagrant-winrm
これ↑しないとこうなります。
-----> Starting Kitchen (v1.4.2) >>>>>> ------Exception------- >>>>>> Class: Kitchen::UserError >>>>>> Message: WinRM Transport requires the vagrant-winrm Vagrant plugin to properly communicate with this Vagrant VM. Please install this plugin with: `vagrant plugin install vagrant-winrm' and try again. >>>>>> ---------------------- >>>>>> Please see .kitchen/logs/kitchen.log for more details >>>>>> Also try running `kitchen diagnose --all` for configuration
WinRMをトランスポートする場合、
gem install winrm-transport
これ↑しないとこうなります。
!!!!!! The `winrm-transport' gem is missing and must be installed or cannot be properly activated. Run `gem install winrm-transport --version '~> 1.0'` or add the following to your Gemfile if you are using Bundler: `gem 'winrm-transport', '~> 1.0'`. >>>>>> ------Exception------- >>>>>> Class: Kitchen::UserError >>>>>> Message: Could not load or activate WinRM::Transport (Could not find 'winrm-transport' (~> 1.0) among 98 total gem(s) Checked in 'GEM_PATH=/Users/tsubauaaa/.gem/ruby/2.2.0:/Users/tsubauaaa/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0', execute `gem env` for more information) >>>>>> ---------------------- >>>>>> Please see .kitchen/logs/kitchen.log for more details >>>>>> Also try running `kitchen diagnose --all` for configuration
次に、.kitchen.ymlですが、こんな具合ので、ご利用ください。
--- driver: name: vagrant synced_folders: - ["./", "/vagrant"] provisioner: name: chef_solo platforms: - name: win2012r2 driver_config: communicator: winrm transport: name: winrm suites: - name: default run_list: - recipe[iis::default] attributes:
Vagrant boxファイルの作成
さて肝心のWindowsのboxファイルですが、
Boxcutter · GitHub
さんが様々なWindowsのboxファイルを提供していますので、こちらを利用させていただきます。
Packerを使ってboxファイルを作成しているので、Packer 0.8.2以上をインストールしましょう。
ちなみにこちらで利用するOSイメージは、評価版のWindows、boxはVirtualboxのでーす。
git clone https://github.com/boxcutter/windows.git cd windows make virtualbox/eval-win2012r2-standard
boxをvmwareとしたければ、
make vmware/eval-win2012r2-standard
ですな。
OSイメージをDLして、Virtualboxで起動して、boxファイルが作成されるので、時間がかかります。
boxファイルが作成されたら、
vagrant box add win2012r2 ./box/virtualbox/eval-win2012r2-standard-nocm-1.0.4.box
として、Vagrant Boxとして利用します。
てな感じで。
ハッピーウィンドウズテスツ!!