October 2011
Intermediate to advanced
300 pages
5h 51m
English
When you have many servers executing the same cron job, it's usually a good idea not to run them all at the same time. If all the jobs access a common server, it may put too much load on that server, and even if they don't, all the servers will be busy at the same time, which may affect their capacity to provide other services.
Puppet's inline_template function allows us to use some Ruby logic to set different runtimes for the job, depending on the hostname.
define cron_random( $command, $hour ) { cron { $name: command => $command, minute => inline_template("<%= (hostname+name).hash.abs % 60 %>"), hour => $hour, ensure => "present", } } cron_random { "hello-world": command ...Read now
Unlock full access