Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
19 changes: 9 additions & 10 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') }
Expand All @@ -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
Expand Down