diff --git a/manifests/cron/db_purge.pp b/manifests/cron/db_purge.pp index eab15383..b8a6c706 100644 --- a/manifests/cron/db_purge.pp +++ b/manifests/cron/db_purge.pp @@ -57,6 +57,10 @@ # all cron jobs at the same time on all hosts this job is configured. # Defaults to 0. # +# [*ensure*] +# (optional) Ensure cron jobs present or absent +# Defaults to present. +# class cinder::cron::db_purge ( $minute = 1, $hour = 0, @@ -66,7 +70,8 @@ class cinder::cron::db_purge ( $user = 'cinder', $age = 30, $destination = '/var/log/cinder/cinder-rowsflush.log', - $maxdelay = 0 + $maxdelay = 0, + Enum['present', 'absent'] $ensure = 'present', ) { include cinder::deps @@ -78,6 +83,7 @@ class cinder::cron::db_purge ( } cron { 'cinder-manage db purge': + ensure => $ensure, command => "${sleep}cinder-manage db purge ${age} >>${destination} 2>&1", environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', user => $user, diff --git a/releasenotes/notes/cron-ensure-bd3b9d51d459ffbe.yaml b/releasenotes/notes/cron-ensure-bd3b9d51d459ffbe.yaml new file mode 100644 index 00000000..f3ecc035 --- /dev/null +++ b/releasenotes/notes/cron-ensure-bd3b9d51d459ffbe.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``cinder::cron::db_purge::ensure`` parameter has been added, so + that status of the cron job can be customized. diff --git a/spec/classes/cinder_cron_db_purge_spec.rb b/spec/classes/cinder_cron_db_purge_spec.rb index 8cc1bcef..2b126688 100644 --- a/spec/classes/cinder_cron_db_purge_spec.rb +++ b/spec/classes/cinder_cron_db_purge_spec.rb @@ -18,6 +18,7 @@ describe 'cinder::cron::db_purge' do shared_examples 'cinder::cron::db_purge' do context 'with required parameters' do it { is_expected.to contain_cron('cinder-manage db purge').with( + :ensure => :present, :command => "cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1", :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', :user => params[:user], @@ -30,6 +31,16 @@ describe 'cinder::cron::db_purge' do )} end + context 'with ensure set to absent' do + before :each do + params.merge!( + :ensure => :absent + ) + end + + it { should contain_cron('cinder-manage db purge').with_ensure(:absent) } + end + context 'with required parameters with max delay enabled' do before :each do params.merge!( @@ -38,6 +49,7 @@ describe 'cinder::cron::db_purge' do end it { should contain_cron('cinder-manage db purge').with( + :ensure => :present, :command => "sleep `expr ${RANDOM} \\% #{params[:maxdelay]}`; cinder-manage db purge #{params[:age]} >>#{params[:destination]} 2>&1", :environment => 'PATH=/bin:/usr/bin:/usr/sbin SHELL=/bin/sh', :user => params[:user],