Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be able to clean out /etc/cron.d #25

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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