Using schedules to limit when resources can be applied
So far, we've looked at what Puppet can do, and the order that it does things in, but not when it does them. One way to control this is to use the
schedule
metaparameter (a parameter you can apply to any type of resource).
When you need to limit the number of times a resource is applied within a specified period, schedule
can help. For example:
exec { "/usr/bin/apt-get update": schedule => daily, }
The most important thing to understand about schedule
is that it can only stop a resource being applied. It doesn't guarantee that the resource will be applied with a certain frequency. For example, the exec
resource shown above has schedule => daily
, but this just represents an upper limit on the number of times the exec
resource can run per day. It won't be applied more than once a day. If you don't run Puppet at all, the resource won't be applied at all.
That being so, schedule
is best used to restrict resources from running when...