Puppet module for cron.
Include with default parameters:
include cron
Include with the singleton pattern:
class { '::cron': }
Log both start and end of cronjobs
class { '::cron':
extra_opts => '-L 2'
}
Cronjobs are placed in /etc/cron.d. If you want cronjobs to be removed automatically when they are removed from a manifest, instead of having to 'ensure => absent', specify purge_dot_d => true when instantiating the cron class
class { '::cron':
purge_dot_dir => true,
}
Please note that this is destructive to existing unmanaged cronjobs in /etc/cron.d! See Below.
Example cronjob
cron::job { 'disk usage':
command => 'df -h',
minute => '0',
hour => '2',
environment => [ '[email protected]' ]
comment => "Send disk usage stats every hour"
}
If you enable purging of files in /etc/cron.d but you don't want puppet to purge cronjobs installed by packages. It is enough that somewhere in your manifest, you specify a file resource for the cronjob in question and ensure that it's present. You don't need to specify any other parameters to the file resource, nor do you need to manage its content.
Example:
include foo
# Ensure foo's cronjob isn't purged
file { "${::cron::dot_dir}/foojob" :
ensure => 'present',
}
See LICENSE file.