/var/log/messages

Nov 5, 2013 - 1 minute read - Comments - Ruby DevOps

serverspec のはじめかた

備忘、ってことで。 とりあえず、bundler を使ってガワを作るあたりまでを控え。

手順としては以下?

  • ディレクトリ掘る
  • bundle init
  • Gemfile に serverspec な記述を追加
  • bundle install –path vendor/bundle
  • serverspec init
  • 試験を書いて bundle exec rake spec

別途動作確認の方向ってことで。

ヤッてみた

ディレクトリを掘って移動して

$ mkdir debian_ut
$ cd debian_ut

bundle init して Gemfile 修正

$ bundle init
$ vi Gemfile
$ cat Gemfile
# A sample Gemfile
source "https://rubygems.org"

gem "serverspec"

その後、bundle install

$ bundle install --path vendor/bundle
Fetching gem metadata from https://rubygems.org/......
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Installing diff-lcs (1.2.4) 
Installing highline (1.6.20) 
Installing net-ssh (2.7.0) 
Installing rspec-core (2.14.7) 
Installing rspec-expectations (2.14.3) 
Installing rspec-mocks (2.14.4) 
Installing rspec (2.14.1) 
Installing serverspec (0.10.13) 
Using bundler (1.3.5) 
Your bundle is complete!
It was installed into ./vendor/bundle

で、これはどうやって実行するんかな。serverspec-init でした。

$ bundle exec serverspec-init
Select OS type:

  1) UN*X
  2) Windows

Select number: 1

Select a backend type:

  1) SSH
  2) Exec (local)

Select number: 1

Vagrant instance y/n: y
Auto-configure Vagrant from Vagrantfile? y/n: y
 + spec/
 + spec/default/
 + spec/default/httpd_spec.rb
 + spec/spec_helper.rb
 + Rakefile

これでこんなことする用意ができた、という訳ですね。

$ bundle exec rspec spec

素晴しひ。

EoPL の exercise 2.11 nsupdate

comments powered by Disqus