From f612d92bfb88bede54d9d2f44ae8686b0d0a5dc8 Mon Sep 17 00:00:00 2001 From: Xav Paice Date: Thu, 25 Jun 2015 15:28:12 +1200 Subject: [PATCH] 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 --- manifests/expirer.pp | 26 +++++++++++++++---------- spec/classes/ceilometer_expirer_spec.rb | 8 ++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/manifests/expirer.pp b/manifests/expirer.pp index a94159f..33f9d0e 100644 --- a/manifests/expirer.pp +++ b/manifests/expirer.pp @@ -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 + } } - } diff --git a/spec/classes/ceilometer_expirer_spec.rb b/spec/classes/ceilometer_expirer_spec.rb index 1df2728..89ba0a3 100644 --- a/spec/classes/ceilometer_expirer_spec.rb +++ b/spec/classes/ceilometer_expirer_spec.rb @@ -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 -- 2.45.2