A collection of task oriented solutions in Puppet

 

Ensure service is running

Challenge

You want to ensure a service is running and have puppet restart it when needed.

Solution

service { "cron":
  ensure => "running",
}

Explanation

There are services that should always be running and if they are ever stopped should be restarted. By setting the ensure service property to “running” (or true) puppet will check for the prescence of the service on each run and restart it when it’s absent.

This property is often used with service enable to ensure a service is both running and starts up immeditaly on boot.

See also