diff --git a/README.md b/README.md index 0e0ab4cc..d0987774 100644 --- a/README.md +++ b/README.md @@ -687,10 +687,9 @@ cronjob. The variable configures the systemd.timer option [onCalender](https://w It defaults to `*-*-* ${fqdn_rand(24)}:${fqdn_rand(60)}:00`. This will start the cleanup service on a daily basis. The exact minute and hour is random per node based on the [fqdn_rand](https://puppet.com/docs/puppet/5.5/function.html#fqdnrand) -method. On non-systemd systems, the cron runs daily and you need the -[puppet/cron](https://forge.puppet.com/puppet/cron) module. On systemd systems -you need the [camptocamp/systemd](https://forge.puppet.com/camptocamp/systemd) -module. Both are optional dependencies and not automatically installed! +method. On non-systemd systems, the cron runs daily and the `$puppetdb_user` needs +to be able to run cron jobs. On systemd systems you need the [camptocamp/systemd](https://forge.puppet.com/camptocamp/systemd) +module, which is an optional dependency and not automatically installed! #### `dlo_max_age` diff --git a/manifests/server.pp b/manifests/server.pp index b671a1b8..524d1f45 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -304,16 +304,15 @@ active => true, } } else { - cron::job{'puppetdb-dlo-cleanup': - ensure => 'present', - minute => fqdn_rand(60), - hour => fqdn_rand(24), - date => '*', - month => '*', - weekday => '*', - command => "/usr/bin/find /opt/puppetlabs/server/data/puppetdb/stockpile/discard/ -type f -mtime ${dlo_max_age} -delete", - user => $puppetdb_user, - description => 'Cleanup old discarded puppetdb reports', + cron { 'puppetdb-dlo-cleanup': + ensure => 'present', + minute => fqdn_rand(60), + hour => fqdn_rand(24), + monthday => '*', + month => '*', + weekday => '*', + command => "/usr/bin/find /opt/puppetlabs/server/data/puppetdb/stockpile/discard/ -type f -mtime ${dlo_max_age} -delete", + user => $puppetdb_user, } } } diff --git a/spec/unit/classes/server_spec.rb b/spec/unit/classes/server_spec.rb index c96cba9f..b81d69c5 100644 --- a/spec/unit/classes/server_spec.rb +++ b/spec/unit/classes/server_spec.rb @@ -89,7 +89,7 @@ it { is_expected.to contain_systemd__unit_file('puppetdb-dlo-cleanup.service') } it { is_expected.to contain_systemd__unit_file('puppetdb-dlo-cleanup.timer').with_enable(true).with_active(true) } - it { is_expected.not_to contain_cron__job('puppetdb-dlo-cleanup') } + it { is_expected.not_to contain_cron('puppetdb-dlo-cleanup') } end describe 'dlo cleanup service can be disabled by params' do @@ -101,13 +101,13 @@ it { is_expected.not_to contain_systemd__unit_file('puppetdb-dlo-cleanup.service') } it { is_expected.not_to contain_systemd__unit_file('puppetdb-dlo-cleanup.timer') } - it { is_expected.not_to contain_cron__job('puppetdb-dlo-cleanup') } + it { is_expected.not_to contain_cron('puppetdb-dlo-cleanup') } end end context 'when systemd is not available' do describe 'by default dlo cleanup is set up with cron' do - it { is_expected.to contain_cron__job('puppetdb-dlo-cleanup').with_ensure('present') } + it { is_expected.to contain_cron('puppetdb-dlo-cleanup').with_ensure('present') } it { is_expected.not_to contain_systemd__unit_file('puppetdb-dlo-cleanup.service') } it { is_expected.not_to contain_systemd__unit_file('puppetdb-dlo-cleanup.timer') } @@ -122,7 +122,7 @@ it { is_expected.not_to contain_systemd__unit_file('puppetdb-dlo-cleanup.service') } it { is_expected.not_to contain_systemd__unit_file('puppetdb-dlo-cleanup.timer') } - it { is_expected.not_to contain_cron__job('puppetdb-dlo-cleanup') } + it { is_expected.not_to contain_cron('puppetdb-dlo-cleanup') } end end end