Ask Your Question

enable a service on boot, but don't ensure

asked 2013-08-23 09:14:35 -0500

banjer gravatar image

I have a service that I want puppet to enable so that it starts on boot, but I don't want puppet to manage its run status. In other words, when the server reboots, this service should automatically start. However, if the developers need to take down the service, then puppet won't try and restart it on them.

I currently have this:

service { 'jboss':
    ensure    => running,
    enable    => true,
    hasstatus => false,
    require   => File['/etc/init.d/jboss'],

Per docs:

ensure: Whether a service should be running. Valid values are stopped (also called false), running (also called true).

It would be ... (more)

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2013-08-25 15:54:07 -0500

Try undef, to avoid puppet to try to start/stop it :

service { 'jboss':
    ensure    => undef,
    enable    => true,
    hasstatus => false,
    require   => File['/etc/init.d/jboss'],
edit flag offensive delete link more


Thanks, this is clean and works perfectly. I confirmed that my service is enabled on boot, and puppet does not attempt to start it.

banjer gravatar imagebanjer ( 2013-08-28 09:49:20 -0500 )edit

Is this officially supported by puppet? We would like to use this but I don't see anything in the documentation. Though the code base may support it today we don't want to rely on an undocumented feature that could change in the future.

thejandroman gravatar imagethejandroman ( 2014-07-25 14:17:25 -0500 )edit

answered 2013-08-23 11:14:59 -0500

extraordinaire gravatar image

updated 2013-08-23 11:17:39 -0500

Sounds like you might want to change your init file instead of puppet (but you could put the init file in place with puppet).

The init file (assuming here you are using upstart, but others have similar options) would just need to register the service for start on boot, but not try to respawn.

You can still define the service (so you can reference it in puppet) like so: service { 'jboss': }

Keep in mind that your service will be started by puppet if you notify the service resource from a different resource (for example by updating a config file).

Good ... (more)

edit flag offensive delete link more


Thanks for the info. You gave me a good idea. I'll see if I can add status to my init script and always have it return 0 (success), and ...(more)

banjer gravatar imagebanjer ( 2013-08-23 13:21:16 -0500 )edit

That could work, though just something to keep in mind: try not to make your systems lie, it will backfire.

extraordinaire gravatar imageextraordinaire ( 2013-08-23 14:26:52 -0500 )edit

You state that if you notify the service from another resource like a config file change, it will start the service(if not running). This is not the behavior i see.. it says it triggered a refresh of the stopped service but the service does not start... puppet will refresh a running service though

Jeff gravatar imageJeff ( 2014-06-13 10:22:33 -0500 )edit

answered 2013-08-25 07:38:06 -0500

golja gravatar image

Hmmm you should probably follow @lavaman idea, but here is another variation.

You can use the parameter enable => true


Whether a service should be enabled to start at boot. This property behaves quite differently depending on the platform; wherever possible, it relies on local tools to enable or disable a given service. Valid values are true, false, manual. Requires features enableable.

And then just change the hasstatus => "echo 0", which will basically lie to puppet that the service is up and running. regardless of the real status.

edit flag offensive delete link more

answered 2013-08-23 11:01:36 -0500

lavaman gravatar image

The simplest thing would be to use an exec to enable the service and leave out the service resource altogether.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-08-23 09:14:35 -0500

Seen: 5,550 times

Last updated: Aug 25 '13