Serverspec ファイルに読み込み権限があるか確認するサンプル
環境
Serverspec
Ansible
操作例
1.ファイルの中身が指定の文字列にマッチするか確認する
describe file('/etc/sysconfig/clock') do
its(:content) { should match /ZONE="Asia\/Tokyo"/ }
end
describe file('/etc/sysconfig/clock') do
its(:content) { should match /ZONE="Asia\/Tokyo"/ }
end
describe file('/etc/sysconfig/clock') do its(:content) { should match /ZONE="Asia\/Tokyo"/ } end
2.ファイルに読み込み権限があるか確認する
%w{
/var/log/httpd/access.log
/var/log/httpd/error.log
}.each do |logfile|
describe file(logfile) do
it { should be_readable.by_user('tent') }
end
end
%w{
/var/log/httpd/access.log
/var/log/httpd/error.log
}.each do |logfile|
describe file(logfile) do
it { should be_readable.by_user('tent') }
end
end
%w{ /var/log/httpd/access.log /var/log/httpd/error.log }.each do |logfile| describe file(logfile) do it { should be_readable.by_user('tent') } end end