A collection of task oriented solutions in Puppet

 

Ensure service is stopped

Challenge

You want to ensure a service is down and have puppet stop it whenever it discovers it running.

Solution

class stopped_service {

  service { 'cron':
    ensure => 'stopped',
  }

}

Explanation

There are services that should never be running on your hosts and if they are discovered should be stopped. By setting the ensure service property to stopped (or false) puppet will check for the presence of the service on each run and stop it when ever it encounters it running.

This property is often used with service disable to ensure a service is both disabled and doesn't start up on boot.

See also