Have puppet ensure a service is running only when not in a maintenance mode

Viewed 1809

I have a basic service check in a puppet manifest I want running most of the time with just

service{ $service_name :
    ensure => "running",
    enable => "true",
}

The thing is there are periods of maintenance I would like to ensure puppet doesn't come along and try to start it back up.

I was thinking creating a file "no_service_start" in a specified path and do a 'creates' check like you could do with a guard for exec but it doesn't look like that's available for the service type.

My next thought was to have the actual service init script do the check for this file itself and just die early if that guard file exists.

While this works in that it prevents a service from starting it manifests itself as a big red error in puppet (as expected). Given the service not starting is a desired outcome if that file is in place I'd rather not have an error message present and have to spend time thinking about if it's "legit" or not.

Is there a more "puppet" way this should be implemented though?

4 Answers
Related