Hi folks,

I'm tying myself in knots trying to figure out the best metaparameters to use here. I want to define an exec that only runs when a service is scheduled to be restarted. It should check the config file and if the syntax is invalid, it should abort restarting the service (i.e. won't kill a running service).

This is what I've got so far:

service { 'dhcpd':
  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
# It isn't run every time puppet runs, but only when dhcpd is to be restarted
exec { 'dhcpd-config-test':
  command     => '/usr/bin/sudo /usr/sbin/dhcpd -t',
  returns     => 0,
  refreshonly => true,
  logoutput   => on_failure,
}

Notify on its own is no good, since if the exec fails, the service gets restarted anyway.

Require on its own is no good, since the exec runs every time.

Is there some way to combine the two?

Thanks,
Jonathan

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/559A6FCA.9030208%40bristol.ac.uk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to