Ask Your Question

How can I make one service stop for another service to restart?

asked 2013-01-28 12:15:55 -0600

typedeaf gravatar image

updated 2013-01-28 16:13:25 -0600

I have a service that requires that another service be stopped before it can successfully restart. How could I set up such a dependency?

Specifically, if a change is made to kdump, then it must rebuild the initrd. But to rebuild the initrd, it must first unload the modules loaded from vmware-tools, or it will fail.

Also, I need to control boot parameters, and I can't think of any other way except by using exec, which feels sloppy. I am doing this:

class kdump::params {
        # there was a bug with the auto setting prior to 6.2, so don ...
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-01-29 16:48:26 -0600

Stefan gravatar image

If you want a another service to stop before restarting you can specify an alternate restart command:

service { 'your_service':
  ensure  => running,
  enable  => true
  restart => '/bin/service dependend_service stop; /bin/service your_service restart; /bin/service dependend_service start'
edit flag offensive delete link more


Good catch, that custom restart option had slipped my mind.

llowder gravatar imagellowder ( 2013-01-29 17:01:53 -0600 )edit

i like this option, but i went with modifying the init script for kdump instead, and controlling it with puppet.

typedeaf gravatar imagetypedeaf ( 2013-01-30 14:19:15 -0600 )edit

answered 2013-01-28 16:51:36 -0600

llowder gravatar image

Unfortunately, execs are the only way at this point, for both of these cases.

For the first issue:

I'd recommend that you create a refresh only exec and have it run a script that will stop the one service and do the update and then restart everything. The script can be put in place with a simple file resource.

For the second issue:

The exec is likely the best option unless you are comfortable trying to create a custom type and/or provider, though I am not sure how clean that route would be either.

For both of these ... (more)

edit flag offensive delete link more


That is indeed unfortunate. Sometimes I ask myself, 'what real benefit does configuration management software give me over a bunch of scripts?', and I gotta be honest, most the time ...(more)

typedeaf gravatar imagetypedeaf ( 2013-01-29 14:14:00 -0600 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2013-01-28 12:15:55 -0600

Seen: 462 times

Last updated: Jan 29 '13