# restart puppet once in a while and randomly delay the restart between 0 and 32 minutes -> splay puppetmaster hammering
0 22 * * */2 root sleep `echo $RANDOM/1000*60 | bc` && /etc/init.d/puppet restart > /dev/null
-
# we restart puppetmaster twice a day to avoid memory problems
58 11 * * * root /etc/init.d/puppetmaster restart > /dev/null
-
# name of puppet agent section in config file
if $puppetversion <= "0.25.4" {
- $puppet_agent_section = 'puppetd'
+ $puppet_agent_name = 'puppetd'
} else {
- $puppet_agent_section = 'agent'
+ $puppet_agent_name = 'agent'
}
# default config file for puppet nodes
}
file { "/usr/local/sbin/check-puppetd.sh":
- source => "puppet://$server/modules/puppet/check-puppetd.sh",
- owner => "puppet",
- group => "puppet",
- mode => 0755,
- ensure => present,
+ content => template("puppet/check-puppetd.sh.erb"),
+ owner => "puppet",
+ group => "puppet",
+ mode => 0755,
+ ensure => present,
}
cron { "puppetd-check":
# check if puppet is running
#
-PID="/var/run/puppet/agent.pid"
+PID="/var/run/puppet/<%= puppet_agent_name %>.pid"
INIT="/etc/init.d/puppet"
-if [ ! -f "$PID" ]; then
+function puppet_start {
+ sleep `echo $RANDOM/2000*60 | bc`
$INIT start
+}
+
+if [ ! -f "$PID" ]; then
+ puppet_start
else
running="$(ps $(cat $PID) &> /dev/null)"
if [ "$?" != "0" ]; then
- sleep `echo $RANDOM/2000*60 | bc`
- $INIT start
+ puppet_start
fi
fi
factpath = $vardir/lib/facter
pluginsync = true
-[<%= puppet_agent_section %>]
+[<%= puppet_agent_name %>]
vardir = /var/lib/puppet
ssldir = $vardir/ssl
server = puppet.<%= domain %>