Manage the cron configuration files.
- /etc/crontab
- /etc/cron.allow
- /etc/cron.deny
- /etc/cron.d/
- /etc/cron.hourly
- /etc/cron.daily
- /etc/cron.weekly
- /etc/cron.monthly
- /etc/cron.yearly
===
This module has been tested to work on the following systems with Puppet v3 (with and without the future parser) and Puppet v4 with Ruby versions 1.8.7, 1.9.3, 2.0.0, 2.1.0 and 2.3.1.
- EL 5
- EL 6
- SLES 10
- SLES 11
- SLES 12
- Ubuntu 12
Note that SLES patches ISC's cron such that if cron.allow and cron.deny are both missing, then root will not be able to access the crontabs. This will cause errors. Please see the Hiera example below.
===
A value of 'undef'
will use the defaults specified by the module.
String for the ensure parameter for the cron package. Valid values are 'installed', 'present' and 'absent'.
- Default: 'installed'
Name of the cron package(s). Specify this to change the platform's default.
- Default: 'USE_DEFAULTS'
String for path to system wide crontab.
- Default: '/etc/crontab'
Name of the owner of the crontab file.
- Default: 'root'
Name of the group of the crontab file.
- Default: 'root'
Filemode of the crontab file. Must use the four-digit octal notation. RegEx: /^[0-9][0-9][0-9][0-9]$/
- Default: '0644'
If the file cron.allow exists, only users listed in it are allowed to use cron, and the cron.deny file is ignored. Valid values are 'present' and 'absent'.
- Default: 'absent'
If cron.allow does not exist, users listed in cron.deny are not allowed to use cron. Valid values are 'present' and 'absent'.
- Default: 'present'
Path to cron.allow.
- Default: '/etc/cron.allow'
Name of the owner of the cron_allow file.
- Default: 'root'
Name of the group of the cron_allow file.
- Default: 'root'
Filemode of the cron_allow file. Must use the four-digit octal notation. RegEx: /^[0-9][0-9][0-9][0-9]$/
- Default: '0644'
Path to cron.deny.
- Default: '/etc/cron.deny'
Name of the owner of the cron_deny file.
- Default: 'root'
Name of the group of the cron_deny file.
- Default: 'root'
Filemode of the cron_deny file. Must use the four-digit octal notation. RegEx: /^[0-9][0-9][0-9][0-9]$/
- Default: '0644'
Path to cron.d directory. Must be an absolute path.
- Default: '/etc/cron.d'
Path to cron.d directory. Must be an absolute path.
- Default: '/etc/cron.hourly'
Path to cron.daily directory. Must be an absolute path.
- Default: '/etc/cron.daily'
Path to cron.weekly directory. Must be an absolute path.
- Default: '/etc/cron.weekly'
Path to cron.monthly directory. Must be an absolute path.
- Default: '/etc/cron.monthly'
Name of the owner of the cron directories cron.d, cron.hourly, cron.daily, cron.weekly and cron.monthly.
- Default: 'root'
Name of the group of the cron.d directories cron.d, cron.hourly, cron.daily, cron.weekly and cron.monthly.
- Default: 'root'
Filemode of the cron.d directories cron.d, cron.hourly, cron.daily, cron.weekly and cron.monthly. Must use the four-digit octal notation. RegEx: /^[0-9][0-9][0-9][0-9]$/
- Default: '0755'
Hash of files managed in cron.hourly, cron.daily, cron.weekly, cron.monthly and cron.yearly. See define cron::fragment for hash structure and examples for examples.
- Default: undef
Array of all users to be included in cron.allow.
- Default: undef
Array of all users to be included in cron.deny.
- Default: undef
Hash that defines the crontab variables SHELL, PATH, MAILTO, HOME. if this variable is undef the module will use the values defined in crontab template which are SHELL=/bin/bash, PATH=/sbin:/bin:/usr/sbin:/usr/bin, MAILTO=root, HOME=/
- Default: undef
Hash for crontab tasks.
- Default: undef
Log entry lines for the periodic jobs section. One entry per line. Leave it unset (undef) to use the OS vendor defaults values.
- Default: undef
Trigger to control if periodic jobs schedules should be included in /etc/crontab.
- Default: true
Boolean to enable the cron service.
- Default: true
String for the ensure parameter for the cron service. Valid values are 'running' and 'stopped'.
- Default: 'running'
Name of the cron service. Specify this to change the platform's default.
- Default: 'USE_DEFAULTS'
Hash of users and user cronjobs.
- Default: undef
Boolean flag to turn off and on merging for Hiera.
- Default: true
Work on Suse
cron::cron_allow: 'present' cron::cron_allow_users: - root
Define crontab variables
cron::crontab_vars: SHELL: /bin/bash PATH: /sbin:/bin:/usr/sbin:/usr/bin MAILTO: root HOME: /root
Create /etc/cron.daily/daily_task
cron::cron_files: 'daily_task': ensure: 'present' type: 'daily' content: | #!/bin/bash # This File is managed by puppet command
Manage /etc/cron.allow
cron::cron_allow: 'present' cron::cron_allow_users: - user1
Manage /etc/cron.deny
cron::cron_deny: 'present' cron::cron_deny_users: - user1
Manage /etc/crontab
cron::crontab_tasks: 'task1': - "* 12 * * 7 username echo 'Hello World'" - "2 2 * * 6 username echo 'tes'" 'task2': - "* 6 * * 7 root echo 'test'"
String for the ensure parameter of the cron fragment file. Valid values are 'absent', 'file' and 'present'.
- Default: 'absent'
String to represent contents of cron job.
- Default: ''
Name of the owner of the fragment file.
- Default: 'root'
Name of the group of the fragment file.
- Default: 'root'
Filemode of the fragment file. Must use the four-digit octal notation. RegEx: /^[0-7]{4}$/ By default it will depend on the used type parameter (see below). If type is set to 'd' it will set mode to '0644', in all other cases it will set mode to '0755'.
- Default: 'USE_DEFAULTS'
The type of cron job. This generally refers to "/etc/cron.${type}/". Valid values are 'd', 'hourly, 'daily', 'weekly', 'monthly' and 'yearly'.
- Default: 'daily'
Often application teams or application users have crontabs that must execute as the application user. This grants the ability to manage those crontab entries.
Example: DBA may want all database systems to have a specific cronjob executed as the oracle or mysql user.
By default this is called from the parent class cron. Data is provided for description.
String for the ensure parameter of the user crontab file.
- Default: 'file'
Owner of the user's crontab file. Default is undef which will result in the filename and user being the same.
- Default: undef
Group owner of the user's crontab file. Default is undef which will result in the filename and group being the same.
- Default: undef
Filemode of the user's crontab file. Must use the four-digit octal notation. RegEx: /^[0-9][0-9][0-9][0-9]$/
- Default: '0600'
Path to the user's crontab file. Leave it unset (undef) to use the OS vendor defaults values.
- Default: undef
Advanced usage Content of the user's crontab file. Warning: Leave alone to use included template.
- Default: template('cron/usercrontab.erb')
Variables to add to user's crontab file. Hint: Will be ignored if $content is set.
- Default: undef
- undef results in:
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO= HOME=/home/
Hash of user's and user crontabs. Hint: Will be ignored if $content is set.
- Default: undef
Simply insert the hiera data in your hiera hierarchy and there will be a hiera_hash of all hiera levels.
Hiera data structure to be used by the parent class cron:
cron::user_crontabs: 'user1': vars: 'SHELL': '/bin/bash' 'MYECHO': '$(which echo)' entries: '# Echo Hello World': - '* 1 * * * $MYECHO "Hello World!" 2>&1' 'user2': vars: 'SHELL': '/bin/bash' 'MYECHO': '$(which echo)' entries: '# Echo Hello World': - '* 3 * * * $MYECHO "Hello user2!" 2>&1'
$user_crontabs => { 'user1' => {'vars' => [ 'SHELL': '/bin/bash', 'MYECHO': '$(which echo)' ], 'entries' => [ '# Echo Hello World': '* 1 * * * $MYECHO "Hello World!"' ]}, 'user2' => {'vars' => [ 'SHELL': '/bin/bash', 'MYECHO': '$(which echo)' ], 'entries' => [ '# Echo Hello World': '* 3 * * * $MYECHO "Hello user2!"' ]} } create_resources(cron::user::crontab, $user_crontabs)