I'm trying to create a relationship between a service resource and two exec resources. The service should trigger the Exec['before'] when something changes and start the Exec['after'] when the service has been modified.
class foobar (
$debug = true
) {
service { "sshd":
ensure => 'stopped',
notify => Exec['before']
}
exec { "before":
command => "/bin/echo before",
refreshonly => true,
}
exec { "after":
refreshonly => true,
command => "/bin/echo after",
}
}
I've tried literally everything but the Exec['before'] keeps getting triggered after the service:
Notice: Compiled catalog for puppet.puppettest.local in environment production in 0.55 seconds
Notice: /Stage[main]/Foobar/Service[sshd]/ensure: ensure changed 'running' to 'stopped'
Notice: /Stage[main]/Foobar/Exec[before]: Triggered 'refresh' from 1 events
Notice: Applied catalog in 0.04 seconds
How can I make sure that the Exec['before'] runs before the service but only if there have been changes to the service and not with every run?
kr