Skip to content

Instantly share code, notes, and snippets.

@zipkid
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zipkid/2397064bf0d715e463b8 to your computer and use it in GitHub Desktop.
Save zipkid/2397064bf0d715e463b8 to your computer and use it in GitHub Desktop.
Puppet cron type wiping an existing crontab if it contains invalid entries
Tested on
- 3.4.2 : FAIL
- 3.6.2 : FAIL
[root@stditop ~]# cat c.pp
cron { 'test':
ensure => present,
command => 'ls',
}
[root@stditop ~]# crontab -l
* * * * * date > /tmp/date1
* * date > /tmp/date2
[root@stditop ~]# puppet apply c.pp
Notice: Compiled catalog for stditop.vm.super-visions.com in environment production in 0.11 seconds
Error: Could not prefetch cron provider 'crontab': Could not parse line "* * date > /tmp/date2" at root:3
Notice: /Stage[main]/Main/Cron[test]/ensure: created
Notice: Finished catalog run in 0.13 seconds
[root@stditop ~]# crontab -l
# HEADER: This file was autogenerated at Tue Jul 15 05:58:46 -0700 2014 by puppet.
# HEADER: While it can still be managed manually, it is definitely not recommended.
# HEADER: Note particularly that the comments starting with 'Puppet Name' should
# HEADER: not be deleted, as doing so could cause duplicate cron jobs.
# Puppet Name: test
* * * * * ls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment