Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
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

1 Answer 1

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,
}
share|improve this answer
2  
That's not ugly at all, I think it's quite elegant. –  Dennis Kaarsemaker Apr 19 '13 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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