Puppet: System Administration Automated

Support

Ticket #669 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Cron environment not set if cron entries exist.

Reported by: jrojas Assigned to: luke
Priority: normal Milestone: elmo
Component: library Version: 0.22.4
Severity: normal Keywords: cron environment
Cc: Triage Stage: Unreviewed
Attached Patches: Code Complexity: Unknown

Description (Last modified by luke)

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.

Attachments

crontab.patch (0.6 kB) - added by jrojas on 06/15/07 03:59:36.

Change History

06/15/07 03:59:36 changed by jrojas

  • attachment crontab.patch added.

06/18/07 08:29:36 changed by luke

  • milestone set to elmo.

06/18/07 23:29:59 changed by luke

  • description changed.

Fixing the quotes in the description.

06/18/07 23:56:39 changed by luke

  • status changed from new to closed.
  • resolution set to fixed.

Applied in [2621], and added unit tests (I could have sworn they already existed, but apparently not).