Hi,

A couple of ways come to mind. Use the 'before' metaparameter in your 
configtest exec. 

You can use ordering syntax '->' between your resources, see 
http://docs.puppetlabs.com/guides/language_guide.html#chaining-resources

See this for a complete overview:
http://docs.puppetlabs.com/learning/ordering.html

Cheers,
Den

On 15/08/2011, at 23:29, Jonathan Gazeley <jonathan.gaze...@bristol.ac.uk> 
wrote:

> Hi all,
> 
> I'm trying to set up a routine in puppet where if a service is scheduled for 
> a restart, eg because of new configs, then a config test is executed first. 
> If the config test fails, the service is not restart (and so keeps running 
> with the old config, rather than stopping and causing an outage).
> 
> So far I've tried this kind of thing:
> 
> # DHCP service
> service { "dhcpd":
>   require => [ File["dhcpd.conf"], Package['dhcp'] ],
>   ensure => running,
>   enable => true,
>   hasstatus => true,
>   hasrestart => true,
>   notify => Exec['dhcpd-config-test'],
> }
> 
> # This exec tests the dhcpd config and fails if it's bad
> exec { "dhcpd-config-test":
>   command => '/etc/init.d/dhcpd configtest 2>&1 | grep "Syntax: OK" | wc -l',
>   returns => 0,
>   refreshonly => true
> }
> 
> 
> In this context, is it better to use notify or require in the service 
> declaration? Using only "notify" seems to not care about the order, and 
> sometimes the dhcpd-config-test is executed *after* the dhcpd service has 
> already been restarted, which is useless.
> 
> Using only "require" doesn't always trigger dhcpd-config-test when dhcpd 
> restarts.
> 
> Is there a better way of reliably triggering a config test before the service 
> restarts, but only when it restarts, and then failing if necessary?
> 
> Thanks,
> Jonathan
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to