If a current cron entry is created via puppet and it includes no environment options, the environment options cannot be added until the entire crontab is blown away and puppet is re-ran.
To reproduce:
use this cron entry:
cron { test_bug: user => root, minute => "*/5", command => "/bin/ls /tmp > /tmp/ls_output", ensure => present }
when you do a crontab -l -u root you should see:
# HEADER This file was autogenerated at Thu Jun 14 17:29:26 -0700 2007 by puppet.
# HEADER While it can still be managed manually, it is definitely notrecommended.
# 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_bug
*/5 * * * * /bin/ls /tmp > /tmp/ls_output
Modify the cron entry:
cron { test_bug: environment => ["MAILTO=admin@somewhere.com","HOME=/tmp"], user => root, minute => "*/5", command => "/bin/ls /tmp > /tmp/ls_output", ensure => present }
make sure it runs on a machine...then check the crontab and you should see:
# HEADER This file was autogenerated at Thu Jun 14 17:29:26 -0700 2007 by puppet.
# HEADER While it can still be managed manually, it is definitely notrecommended.
# 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_bug
*/5 * * * * /bin/ls /tmp > /tmp/ls_output
Notice if you ran puppetd with --verbose/--debug there were 0 changes.
No remove the crontab:
crontab -r -u root
Re-run puppet...
Notice it created the entries.
crontab -l -u root
# HEADER This file was autogenerated at Thu Jun 14 17:29:26 -0700 2007 by puppet.
# HEADER While it can still be managed manually, it is definitely notrecommended.
# 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_bug
MAILTO=admin@somewhere.com
HOME=/tmp
*/5 * * * * /bin/ls /tmp > /tmp/ls_output
Now if you manually edit the cron and remove one of those environment settings it will notice that the entry is missing and add it.
Now if you remove both the environment entries puppet won't notice and wont add them.