7
7
Installs and manages cron jobs. Every cron resource requires a command
8
8
and user attribute, as well as at least one periodic attribute (hour,
9
9
minute, month, monthday, weekday, or special). While the name of the cron
10
job is not part of the actual job, it is used by Puppet to store and
10
job is not part of the actual job, the name is stored in a comment beginning with
11
`# Puppet Name: `. These comments are used to match crontab entries created by
12
Puppet with cron resources.
13
If you specify a cron resource that duplicates the scheduling and command
14
used by an existing crontab entry, then Puppet will take no action and
15
defers to the existing crontab entry. If the duplicate cron resource
16
specifies `ensure => absent`, all existing duplicated crontab entries will
17
be removed. Specifying multiple duplicate cron resources with different
18
`ensure` states will result in undefined behavior.
14
If an existing crontab entry happens to match the scheduling and command of a
15
cron resource that has never been synched, Puppet will defer to the existing
16
crontab entry and will not create a new entry tagged with the `# Puppet Name: `
410
return true unless self[:special]
411
return true if self[:special] == :absent
412
# there is a special schedule in @should, so we don't want to see
413
# any numeric should values
414
[ :minute, :hour, :weekday, :monthday, :month ].each do |field|
415
next unless self[field]
416
next if self[field] == :absent
417
raise ArgumentError, "#{self.ref} cannot specify both a special schedule and a value for #{field}"
412
421
# We have to reorder things so that :provide is before :target
414
423
attr_accessor :uid
425
# Marks the resource as "being purged".
429
# @note This overrides the Puppet::Type method in order to handle
430
# an edge case that has so far been observed during testig only.
431
# Without forcing the should-value for the user property to be
432
# identical to the original cron file, purging from a fixture
433
# will not work, because the user property defaults to the user
434
# running the test. It is not clear whether this scenario can apply
435
# during normal operation.
437
# @note Also, when not forcing the should-value for the target
438
# property, unpurged file content (such as comments) can end up
439
# being written to the default target (i.e. the current login name).
441
self[:target] = provider.property_hash[:target]
442
self[:user] = provider.property_hash[:target]
417
447
name = name.intern