make crontab for expirer optional

This adds an 'enable_cron' switch to ceilometer::expirer, defaults to
true, so that if we want to configure the TTL but don't want to run the
expiry job via cron we don't have to.

Closes-Bug: 1468937

Change-Id: I7fd89e58f70ae41628e769ed24f1ef5c15af51f9
This commit is contained in:
Xav Paice 2015-06-25 15:28:12 +12:00 committed by Gael Chamoulaud
parent 4d18c07eed
commit f612d92bfb
2 changed files with 24 additions and 10 deletions

View File

@ -26,6 +26,10 @@
# Should be a valid integer
# Defaults to '-1' to disable TTL and keep forever the datas.
#
# [*enable_cron*]
# (optional) Whether to configure a crontab entry to run the expiry.
# Defaults to true.
#
# [*minute*]
# (optional) Defaults to '1'.
#
@ -44,6 +48,7 @@
class ceilometer::expirer (
$time_to_live = '-1',
$enable_cron = True,
$minute = 1,
$hour = 0,
$monthday = '*',
@ -59,16 +64,17 @@ class ceilometer::expirer (
'database/time_to_live': value => $time_to_live;
}
cron { 'ceilometer-expirer':
command => $ceilometer::params::expirer_command,
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
user => 'ceilometer',
minute => $minute,
hour => $hour,
monthday => $monthday,
month => $month,
weekday => $weekday
if $enable_cron {
cron { 'ceilometer-expirer':
command => $ceilometer::params::expirer_command,
environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh',
user => 'ceilometer',
minute => $minute,
hour => $hour,
monthday => $monthday,
month => $month,
weekday => $weekday
}
}
}

View File

@ -54,6 +54,14 @@ describe 'ceilometer::expirer' do
)
end
context 'with cron not enabled' do
before do
params.merge!({
:enable_cron => false })
end
it { is_expected.to_not contain_cron('ceilometer-expirer') }
end
it 'configures database section in ceilometer.conf' do
is_expected.to contain_ceilometer_config('database/time_to_live').with_value( params[:time_to_live] )
end