Version information
This version is compatible with:
- Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.4.0 < 6.0.0
- Ubuntu
Start using this module
Add this module to your Puppetfile:
mod 'pegas-cron', '0.4.0'
Learn more about managing modules with a PuppetfileDocumentation
Puppet module to manage cron jobs in a tidy way
Table of Contents
- Description
- Setup - The basics of getting started with cron
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Description
This module is an interface for cron jobs with the main idea to be tidy. That means that any jobs that are not managed
should not exist. Once you switch all cron jobs to this module, simply removing the definition is sufficient without
worrying about setting ensure => disable
and waiting for changes to propagate.
Setup
Beginning with cron
To start out with cron:
include cron
This will start purging all unmanaged cron resources and also make sure the 'cron' package is installed and the service is running.
WARNING #1: All existing unmanaged cron jobs will be purged!
Usage
Also manage /etc/cron.d directory
class { 'cron':
purge_crond => true,
}
Wipe it all out
class { 'cron':
ensure => absent,
}
cron::job example
cron::job { 'backup':
user => 'backup', # default: 'root'
minute => '3-59/5',
hour => '9-17',
monthday => '*/2',
month => [ 4, 8, 12 ],
weekday => '0-4',
}
Custom
Cron::*
time types are a lot stricter than builtincron
ones. Careful - this may break existing cron jobs you are converting.
cron::whitelist example
cron::whitelist { 'pkg_backup': }
This will make /etc/cron.d/pkg_backup
immune, and keep the file's contents untouched.
Reference
Classes
Public Classes
cron
: Main entry point into all cron-related resources on the host. It purges by default. You've been warned!
Private Classes
cron::config
: Various cron configuration filescron::install
: This class handles cron packages.cron::purge
: This is where all the purging magic happens. Purge unmanaged cron jobs and also, optionally, purge/etc/cron.d
directory.cron::remove
: This class handles removal of all cron-related resources.cron::service
: This class handles cron service.
Defined types
cron::job
: Cron job defined type with a bit of magic dust sprinkled all over.cron::whitelist
: Use this to whitelist any system cron jobs you don't want this module to touch. This will make sure/etc/cron.d/${title}
won't get deleted
Functions
cron::prep4cron
: This functions prepares any cron::job custom timing value to be used as Puppet internal cron's resource argument
Custom Types
Cron::Minute
Cron::Hour
Cron::Monthday
Cron::Month
Cron::Weekday
More information
Parameters, examples, and more: REFERENCE.
Limitations
- Made for and tested only on the following Ubuntu distributions:
- 14.04
- 16.04
- 18.04 (currently tested in Docker containers)
Cron::*
custom types are strict!- All cron jobs managed by built-in
cron
type are fair play. They won't be purged as long as they're in the catalog. But using this module'scron::job
type does have its advantages.
Development
I'll be happy to know you're using this for one reason or the other. And if you want to contribute - even better. Feel free to submit an issue / fire up a PR / whatever.
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
[0.4.0] - 2018-03-05
Added
- Acceptance testing on Ubuntu 18.04.
- Acceptance tests for
cron::job
. REFERENCE.md
generated using puppet-strings.
Changed
- Travis configuration prettified.
- Documentation cleanups.
- Acceptance tests split up into multiple spec files.
Fixed
- Removal order that led to (through a chain of other events) a non-working
ensure => absent
on Ubuntu 18.04. - Proper trailing newline handling for
/etc/cron.allow
and/etc/cron.deny
.
[0.3.0] - 2017-12-21
Added
- The Changelog.
$::cron::purge_noop
parameter that disables crontab purging (but you'll still see noop notices).$::cron::allowed_users
and$::cron::denied_users
parameters that manage users thrucron.allow
andcron.deny
files.
Changed
- A few more acceptance tests.
- Idempotence tests refactored.
- Adding/removing cron entries does not reload the cron service anymore.
Cron::Minute
andCron::Hour
now accept ranges and patterns like*/2
inside an array.- Because of the previous change,
cron::prep4cron
function doesn't sort the array anymore, it simply throws away repeated values. - All
Cron::
types accept a minimum of 2 array elements instead of 1. - Updated tests for
Cron::
types as rspec-puppet now supports these natively. w00h00! - Added
require ::cron
to thecron::job
define. It is now not necessary to include it. Beware though, that this might break if you don't have any cron jobs defined. No purging for you then!
Fixed
- Updated documentation for
cron::prep4cron()
function.
[0.2.0] - 2017-02-10
Added
- This is the first clean release of the cron module.
Changed
- Removed all incron references (this used to be cron + incron module).
[0.1.0] - 2017-02-08 [YANKED]
Added
- This used to be cron + incron module. After reading lots of suggestions about single-purposeness of modules, I decided to split this module into two and make this a pure cron-only one.
- This is the last point where you can check the previous approach.
- Doesn't seem feasible to release this, hence the [YANKED] tag.
Dependencies
- puppetlabs/stdlib (>= 4.13.0 < 5.0.0)