puppetlabs/puppet — pull request #1216 by stschulte (2012-10-07 16:06:15+00:00)
Title: (#16809) Use only one record_type in cron provider

The cronprovider defines two record_types `:crontab` and `:freebsd_special`
to handle the following crontab records:

@daily /bin/my_daily_command
0 0 * * * /bin/my_daily_command

This has a few issues:

a)
The merging of the name (the comment before the cronentry itself) and
the environment variables only happens for the `:crontab` record_type
but not for the `:freebsd_special` record_type so information may get
lost (redmine ticket #16809)

b)
When parsing an existing record the record_type can be automatically
determined (depending on which regex matched) but when creating a new
entry, the record_type is undefined and the default `:crontab` is used.
So if a new cronentry is created with the `:special` property set it is
still treated as a crontab entry (so the to_line hook of the `:crontab`
record_type is used and not of the `:freebsd_special` record_type)
which is kind of confusing.

c)
It is really hard to change the time of a cronentry from the special
format to a normal format (or vise versa) e.g. if we already have the
following cronentry

# Puppet Name: foo
* * * * * /bin/foo

and we have defined the following resource

cron { "foo":
special => daily,
}

the resource is treatd as in sync because the existing cronentry is
parsed as a :crontab record_type and this record_type doesn't define a
:special field that could be out of sync

This patch now only uses one record_type that internally parses the
timefield as either the old format (minute,hour,monthday,month,weekday)
or the special format. This way the above issues go away (but the
different to_line, post_parse hooks get a bit more difficult to handle
both entries)

= NOTE
After I'm done I'm not so conviced anymore that this was the best approach. I may try the other route: Patching the `parsedfile` provider to be able to migrate an existing record from one record_type to another and automatically determine the best-fit record_type of newly created records. I'd still like the pull request to be merged because then there are at least some spec tests as a starting point.