LoginSignup
0
1

More than 5 years have passed since last update.

Inspec

Last updated at Posted at 2019-01-09

公式サイト

https://www.inspec.io/docs/

コマンド例

inspec exec test.rb -t ssh://ユーザ名@IPアドレス -i Pathto鍵ファイル --sudo --log-level=debug

rbファイルの記述例

テスト用のコマンドを実行したいとき

control 'command' do
  title 'コマンド実行'

  describe command('cat /etc/ssh/sshd_config | grep Port | grep 22') do
    its('exit_status') { should eq 0 } # 終了コードが0であることで確認
  end
end

ファイルの中身を確認したいとき

control 'file' do
  title 'ファイルチェック'

  describe file('/etc/ssh/sshd_config') do
    its('content') { should match '^Port 22$' } # 終了コードが0であることで確認
  end
end

json形式ファイルの中身を確認したいとき

control 'json' do
  title 'json形式で設定を確認'

  describe json('/tmp/work/output.json') do
    its(['json, 0, 'Tags', 0, 'Value']) { should eq 'test' } # testタグがついていることを確認
 end
end
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1