Serverspec cronの設定を検証するサンプル

環境
RHEL8.6
Serverspec

構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
describe cron do
it { should have_entry(xxxx).with_user('ユーザー名')
end
describe cron do it { should have_entry(xxxx).with_user('ユーザー名') end
describe cron do
   it { should have_entry(xxxx).with_user('ユーザー名')
end

エントリーあり
特定のエントリが存在するかどうか cron をテストするには、have_entry matcher を使用する必要があります。

操作例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
describe cron do
it { should have_entry('*/10 * * * * /opt/data/monitor/cpu.sh').with_user('cft') }
it { should have_entry('*/19 * * * * /opt/data/monitor/memory.sh').with_user(cft') }
end
describe cron do it { should have_entry('*/10 * * * * /opt/data/monitor/cpu.sh').with_user('cft') } it { should have_entry('*/19 * * * * /opt/data/monitor/memory.sh').with_user(cft') } end
describe cron do
  it { should have_entry('*/10 * * * * /opt/data/monitor/cpu.sh').with_user('cft') }
  it { should have_entry('*/19 * * * * /opt/data/monitor/memory.sh').with_user(cft') }
end

 

Ansible

Posted by arkgame