Skip to content

Commit

Permalink
Be able to clean out /etc/cron.d
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Dec 26, 2013
1 parent 2298b39 commit 7b89a0a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
fixtures:
symlinks:
cron: "#{source_dir}"
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib"

2 changes: 2 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ summary 'A module to manage cron jobs via /etc/cron.d'
description 'A module to manage cron.d cron jobs (as well as environment settings for these jobs, and common helpers such as cron::daily)'
project_page 'https://github.com/torrancew/puppet-cron'

dependency 'puppetlabs/stdlib', '>= 2.0.0'

14 changes: 13 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
# Parameters:
#
# [*clean*]
# Default false - if we should clean /etc/cron.d/ of any jobs we find which are unmanaged
#
# Actions:
#
# Requires:
Expand All @@ -12,7 +15,16 @@
# include 'cron'
# class { 'cron': }

class cron {
class cron ( $clean = false ) {
include cron::install
if str2bool($clean) {
file { '/etc/cron.d':
ensure => directory,
recurse => true,
force => true,
replace => true,
purge => true,
}
}
}

9 changes: 8 additions & 1 deletion spec/classes/cron_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require 'spec_helper'

describe 'cron' do
it { should include_class( 'cron::install' ) }
context 'unclean' do
it { should include_class( 'cron::install' ) }
end
context 'clean' do
let(:params) { {:clean => true} }
it { should include_class( 'cron::install' ) }
it { should contain_file( '/etc/cron.d' ) }
end
end

0 comments on commit 7b89a0a

Please sign in to comment.