I don't follow. Do you mean that if any resource at all on the target
node is updated by Puppet, then the second Exec runs? That should not
be. An Exec marked with "refreshonly => true" should only run if it
receives a signal.
Or do you mean that the *first* command is executing on every Puppet
run? That's not influenced by the DSL fragment you quoted.
Here's a complete example that should work:
====
class test::manage_my_file {
$my_file = '/tmp/test'
$target_string = 'So long, and thanks for all the fish'
file { "${my_file}": ensure => 'file' }
exec { 'command_one':
command => "echo '${target_string}' >> ${my_file}",
unless => "grep -q '${target_string}' ${my_file}",
require => File["${my_file}"]
}
exec { 'command_two':
command => "/bin/cp ${my_file} /tmp/test2",
refreshonly => true,
subscribe => Exec[ 'command_one' ]
}
}
node default {
include 'test::manage_my_file'
}
====
With that as your site.pp (to exclude any possibility of influence by
other manifest files), you should see Exec['command_one'] run unless
the string "So long, and thanks for all the fish" is present in file /
tmp/test on the target node (any target node). If Exec['command_one']
runs then Exec['command_two'] should run after. If
Exec['command_one'] *does not* run, then neither should
Exec['command_two'].
If Exec['command_one'] runs when /tmp/test already contains the target
string, or if Exec['command_two'] runs when Exec['command_one'] did
not first run in the same session, then you should file a bug report.
If this approach does not appear to work when you adapt it to your
problem, then do check at least these things:
1) that your 'unless' command is exiting with the expected return
code. If it always returns a false (non-zero) exit code then the two
execs will always run.
2) that no other resource is set to 'notify' Exec['command_two']. If
you use resource defaults anywhere in your configuration then don't
forget to check those, too. Also, beware of any resource notifying a
collection of Execs, as such a collection could easily include
Exec['command_two'] without explicitly naming it.
John