Ask Your Question

resource dependency while enforcing resource attributes

asked 2015-03-10 17:15:13 -0500

John Ting gravatar image

I have the following in my module's manifest file.

service {'centrify-sshd': ensure => running, enable => true, hasrestart => true, hasstatus => true, subscribe => File['/etc/centrifydc/ssh/sshd_config'] }

file {'/etc/centrifydc/ssh/sshdconfig': mode => "0600", owner => root, group => root, content => template("mymodule/sshdconfig.erb"), }

The dependency works, ie. when the file changes, the service is restarted. However, I would also like to have the service be started if it happens to be off. ie. if some sys-admin or other system process stops the sshd service, I want the manifest to just turn it on.

Puppet doesn't do this. The service will only restart if the file changes. And if the file changes while the service is off, an attempted restart causes an error, because it really just needs a "start".

Is there a way to restart if file changes AND start service if it's not running?

edit retag flag offensive close merge delete


service ensure => running should start the service if it's not running. It doesn't do that???

lorcutt gravatar imagelorcutt ( 2015-03-10 21:59:45 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-03-11 09:44:30 -0500

John Ting gravatar image

Thanks for the input thus far. I found the problem. It lies in the service's rc script - centrify-sshd. The "status" input returns a 0 exit code even if the service is stopped... So puppet thinks it's running. This is a bug with centrify-sshd rc script.

edit flag offensive delete link more


Ah that would prevent the service from restarting yes :P

PorkCharSui gravatar imagePorkCharSui ( 2015-03-11 10:36:10 -0500 )edit

answered 2015-03-11 05:35:30 -0500

PorkCharSui gravatar image

You have a dependency issue... You've "subscribed" the service to the file. This means the service will only update if the file changes. Use "require" instead of "subscribe". Then the service will get updated even if the file doesn't.

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: 2015-03-10 17:15:13 -0500

Seen: 36 times

Last updated: Mar 11 '15