Resolution: Won't Fix
Affects Version/s: PUP 3.8.0
Fix Version/s: None
This is a variation on
PUP-2748, where the exec uses refreshonly
If you use onlyif => 'false' in 'step 1' nothing is triggered. If 'step 1' acts, then the 'onlyif' behavior in 'step 2' means the exec command isn't invoked, but triggers 'step 3'. This behavior is definitely inconsistent.
Some paraphrased notes from Charlie Sharpsteen on why that might be:
The issue appears to be that Exec[step 2] is generating or propagating a refresh event when it isn't actually firing. So, refreshes are wierd... I suspect it's just propagating regardless of the hackery Exec has to conditionally run commands.
Refreshes were originally built to trigger service restarts — so I'd bet there is an assumption that refreshing a resource will "do something" and thus should be propagated. refreshonly was totally bolted onto that service restart mechanism and probably violates several of the original assumptions.
So, what happens is that the event_manager queues up refresh events if a refreshed resource "restarted successfully": https://github.com/puppetlabs/puppet/blob/4.2.2/lib/puppet/transaction/event_manager.rb#L32-L39
That gets set depending on how process_callback goes, which always returns true if the method completes without raising an error: https://github.com/puppetlabs/puppet/blob/4.2.2/lib/puppet/transaction/event_manager.rb#L152
In the case of an Exec, what gets called there is resource.refresh.