Serverspec サービスの起動確認の書き方のサンプル
環境
Serverspec
Ansible
操作例
1.指定のサービスが起動していて自動起動設定されているか確認する
describe service('httpd') do
it { should be_enabled }
it { should be_running }
end
2.指定のポートをListenしているか確認する
describe port("8080") do
it { should be_listening }
end
3.curlでHTTPアクセスして200 OKが返ってくるか確認する
describe command('curl http://127.0.0.1:8080/_plugin/head/ -o /dev/null -w "%{http_code}\n" -s') do
its(:stdout) { should match /^200$/ }
end