2019-10-11 17:49:18 -04:00
|
|
|
# frozen_string_literal: true
|
2018-07-06 09:07:39 -04:00
|
|
|
|
|
|
|
title 'Test logrotate installation'
|
|
|
|
|
2021-02-22 11:30:01 -05:00
|
|
|
control 'logrotate-pkg.pkg.installed' do
|
|
|
|
title 'The required package should be installed'
|
|
|
|
|
|
|
|
pkg =
|
|
|
|
case platform[:name]
|
|
|
|
when 'redhat', 'centos', 'fedora', 'amazon', 'oracle'
|
|
|
|
'cronie'
|
|
|
|
else
|
|
|
|
'logrotate'
|
|
|
|
end
|
2018-07-06 09:07:39 -04:00
|
|
|
|
2021-02-22 11:30:01 -05:00
|
|
|
describe package(pkg) do
|
|
|
|
it { should be_installed }
|
|
|
|
end
|
2018-07-06 09:07:39 -04:00
|
|
|
end
|
|
|
|
|
2021-02-22 11:30:01 -05:00
|
|
|
control 'logrotate-config.file.managed' do
|
|
|
|
title 'Verify the configuration file'
|
|
|
|
|
|
|
|
describe file('/etc/logrotate.conf') do
|
|
|
|
it { should exist }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
end
|
2018-07-06 09:07:39 -04:00
|
|
|
end
|
|
|
|
|
2021-02-22 11:30:01 -05:00
|
|
|
control 'logrotate-directory.file.directory' do
|
|
|
|
title 'Verify the `.d` directory'
|
|
|
|
|
|
|
|
describe file('/etc/logrotate.d') do
|
|
|
|
it { should be_directory }
|
|
|
|
it { should be_owned_by 'root' }
|
|
|
|
it { should be_grouped_into 'root' }
|
|
|
|
its('mode') { should cmp '0755' }
|
|
|
|
end
|
2018-10-26 07:54:02 -04:00
|
|
|
end
|
|
|
|
|
2021-02-22 11:30:01 -05:00
|
|
|
control 'logrotate.service.running' do
|
|
|
|
title 'The service should be installed, enabled and running'
|
|
|
|
|
|
|
|
only_if('Disabled on Arch Linux') do
|
|
|
|
!%w[arch].include?(platform[:name])
|
|
|
|
end
|
|
|
|
|
|
|
|
service =
|
|
|
|
case platform[:name]
|
|
|
|
when 'redhat', 'centos', 'fedora', 'amazon', 'oracle'
|
|
|
|
'crond'
|
|
|
|
else
|
|
|
|
'cron'
|
|
|
|
end
|
|
|
|
|
|
|
|
describe service(service) do
|
|
|
|
it { should be_installed }
|
|
|
|
it { should be_enabled }
|
|
|
|
it { should be_running }
|
|
|
|
end
|
2018-07-06 09:07:39 -04:00
|
|
|
end
|