I think I got this. My main issue was the 'true' logic with an 'onlyif', 
because that's always only going to either run (= and therefore meet the 
requirement) or not run at all (= which also meets the requirement since 
it's not a failure).

I feel the choice of words here leaves room for confusion. Like "unless"... 
unless succeeds? unless fails? "requires" also leaves some amgiuity as 
well, since it considers the requirement met as long as the required 
resource did not explicitly return a failure. So "notrun" is just as good 
as success, which to me doesn't really intuitively match what I think 
"require" means.

Here's a set of tests that illustrate all this more clearly, in case it 
helps someone else that stumbles on this post:
  exec { "test1": command => "/bin/false", unless => "/bin/true" }  # 
unless = only if this fails
  notify { "false, unless true fails, which it wont: this should not fail 
(notrun) and i should see this": require => Exec["test1"] }
  exec { "test2": command => "/bin/false", onlyif => "/bin/true" }   # 
onlyif = only if this returns true
  notify { "false, but only if true: this should fail and i should not see 
this": require => Exec["test2"] }
  exec { "test3": command => "/bin/true", unless => "/bin/true" } # unless 
= only if this fails
  notify { "true, unless true fails, which it wont: this should not run 
true (notrun) and i should see this": require => Exec["test3"] }
  exec { "test4": command => "/bin/true", onlyif => "/bin/false" } # onlyif 
= only if this returns true
  notify { "true, but only if false returns true, which it wont: true will 
be run and i should see this": require => Exec["test4"] }


-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/e9c2a7a4-148b-4337-aba7-acf308e7cbe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to