]> review.fuel-infra Code Review - puppet-modules/puppet-ceilometer.git/commitdiff
make crontab for expirer optional
authorXav Paice <xav@catalyst.net.nz>
Thu, 25 Jun 2015 03:28:12 +0000 (15:28 +1200)
committerGael Chamoulaud <gchamoul@redhat.com>
Mon, 29 Jun 2015 10:49:05 +0000 (12:49 +0200)
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
spec/classes/ceilometer_expirer_spec.rb

index a94159f58f0632f3c004514bdcc29a5c21ca3507..33f9d0ef39b4cca83982c86b8b1a3c13fa91788b 100644 (file)
 #   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
+    }
   }
 
-
 }
index 1df2728630e8964170bf3db4957654202a931f87..89ba0a301963741c408ba433ad8e99f2aef0018f 100644 (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