ubuntu16.04.1で動作確認しましたが、
(gemで入れたものとaptで入れたものは名前が変わっているのかそもまま動かなくてつらみ。
SpecInfra
が Specinfra
になっていたり、DetectOSがDetectOsだったり)
参考
インストール
gem install serverspec-runner
-
/usr/local/bin/serverspec-runner
が入る。
mkdir test; cd test
serverspec-runner -r .
# yを入力
設定
vim ./scenario.yml
scenario.yml
example:
- anyhost-01
---
anyhost-01:
- host: 127.0.0.1
+ host: 192.168.0.9
実行
serverspec-runner -t mkd
- 実行される spec ファイルは
spec/example/default.rb
結果
|description | result |
|:----------------------------------------------------------------|:------:|
|example@anyhost-01(192.168.0.9) | |
| User "root" | |
| should exist | OK |
| should have uid 0 | OK |
| should have home directory "/root" | OK |
| Group "root" | |
| should have gid 0 | OK |
| Filesystem | |
| File "/" | |
| should be mounted | OK |
| Host "www.google.com" | |
| should be resolvable | OK |
| should be reachable | OK |
| Command "dmesg | grep "FAIL\|Fail\|fail\|ERROR\|Error\|error"" | |
| exit_status | |
| should not eq 0 | NG |
コンソール向けに出力
serverspec-runner -t aa