serverspec

とりあえず wordpress な試験を書きはじめてみます。
まず、以下を実行。

$ serverspec-init 
Select a backend type:

  1) SSH
  2) Exec (local)
  3) Puppet providers (local)

Select number: 1

Input target host name: 192.168.33.10
 + spec/
 + spec/192.168.33.10/
 + spec/192.168.33.10/httpd_spec.rb
 + spec/spec_helper.rb
 + Rakefile
$ ls
chef-repo Rakefile spec Vagrantfile

とりあえず vagrant up して rake spec してみようかな。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Running any VM customizations...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
cause things such as shared folders to not work properly. If you see
shared folder errors, please update the guest additions within the
virtual machine and reload your VM.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.1
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
$ rake spec

あ、失敗。やっぱ確認しないと駄目ですね。以下に修正して試験パスを確認してます。

require 'spec_helper'

describe 'apache2' do
  it { should be_installed }
  it { should be_enabled   }
  it { should be_running   }
end

describe 'port 80' do
  it { should be_listening }
end

describe '/etc/apache2/httpd.conf' do
  it { should be_file }
end

describe '/etc/apache2/sites-available/wordpress.conf' do
  it { should be_file }
  it { should contain "ServerName precise32" }
end

describe '/etc/apache2/sites-enabled/wordpress.conf' do
  it { should be_file }
  it { should contain "ServerName precise32" }
end

試験実施の観点としては以下が、なのかどうか。

$ ls
apache2  apt  build-essential  logrotate  mysql  openssl  php  wordpress  xml

ええと、確認着手するにあたって起点は apache2/recipes/default.rb になるのかどうか。あと、node な変数については apache2/attributes/default.rb になるのかな。

つうか

最初の設定で接続方法と接続先の識別子を投入することで .ssh/config なソレを使って試験ができる、というのはなかなか嬉しいです。
別途、ローカルな (Vagrant な) 試験からリモートな試験に移行する時の諸々も確認してみたいと思ってます。
この件、継続して確認の方向にて。