3

I have an issue with puppet.

I need to define a service with "ensure=>running" but its config files can only be changed while the service is stopped. The default behaviour seems to be that the service is restarted after config files changed (connected through notify).

Is this representable with puppet? And if so, how?

Regards Jan

  • Of course you could do it with an exec, but that isn't really the preferred way. – Zoredache Apr 19 '13 at 8:18
  • @Zoredache : I thought about that too. But there should be a preferred way, shouldn't it? – roehrijn Apr 19 '13 at 14:32
  • Not really this seems pretty uncommon. Most services simply parse and read the config file when they are starting. Changing the configuration file while running doesn't do anything. – Zoredache Apr 19 '13 at 17:11
  • @Zoredache: I need this for JBoss. It frequently rewrites its config file because some runtime information is stored in that file as well. – roehrijn Apr 25 '13 at 11:24
  • See serverfault.com/questions/882811/… – bodgit Apr 10 '18 at 9:17
4

Here is an ugly method with an exec. There may be better solutions.

# push file system, but don't replace 'real' config file
file { '/etc/service/config.staging':
  ensure => present,
  source => 'puppet:///modules/service/config',
  notify => Exec['reload-service']
}

# stop service, update config, start service
exec { 'reload-service':
  command => '/etc/init.d/service stop; cp /etc/service/config.staging /etc/service/config; /etc/init.d/service start',
  refreshonly => true,
  path => ["/usr/sbin", "/usr/bin", "/sbin", "/bin/"],
  logoutput => false,
}
  • 2
    That's not ugly at all, I think it's quite elegant. – Dennis Kaarsemaker Apr 19 '13 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.