# 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'.
#
class ceilometer::expirer (
$time_to_live = '-1',
+ $enable_cron = True,
$minute = 1,
$hour = 0,
$monthday = '*',
'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
+ }
}
-
}
)
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