Skip to content

Instantly share code, notes, and snippets.

@npwalker
Last active October 7, 2016 21:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save npwalker/7536301 to your computer and use it in GitHub Desktop.
Save npwalker/7536301 to your computer and use it in GitHub Desktop.
A puppet manifest to disable the pe-puppet daemon and instead enable a cron job to run puppet with a random starting time. This will help avoid a thundering herd problem.
$runinterval = 30 #minutes
$first_run = fqdn_rand($runinterval)
$second_run = $first_run + $runinterval
cron { 'cron.puppet':
command => "/opt/puppetlabs/bin/puppet agent -t > /dev/null",
user => "root",
minute => [ $first_run, $second_run ],
}
# make sure we haven't started the puppet daemon ever
# this might break a report on an agent that triggers this via a daemonized run.
service { 'puppet':
enable => false,
ensure => stopped,
require => Cron['cron.puppet'],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment