Unless/Onlyif vs Subscribe/Refreshonly

818 views
Skip to first unread message

Douglas Garstang

unread,
Aug 17, 2012, 12:23:46 PM8/17/12
to Puppet Users
When chaining execs together, and wanting to ensure that exec
resources are not executed on every puppet run, which method is
better? Using unless/onlyif or subscribe/refreshonly?

With unless/onlyif, the exec is evaluated every time. With
subscribe/refreshonly, the exec is only executed when a dependent
resource changes....

Doug.

jcbollinger

unread,
Aug 17, 2012, 5:01:15 PM8/17/12
to puppet...@googlegroups.com


Neither mechanism is better than the other in any general sense.  They serve different purposes, and it is uncommon that both are applicable to any given configuration objective.

The 'unless' and 'onlyif' (and 'creates') parameters serve as means for an Exec to determine whether it is already in sync.  If it is, then its command will not be run, in the same way that a File that is already in sync will not redundantly download its content.  This should also have implications for reports, etc..  The 'unless' and/or 'ifonly' commands must run every time, though.

The 'refreshonly' parameter, on the other hand, makes application of the Exec conditional on (and subsequent to) one or more other resources changing, sort of like an 'on update' trigger in a database.

In any given case, you should use whichever approach makes sense.


John

Douglas Garstang

unread,
Aug 17, 2012, 5:23:43 PM8/17/12
to puppet...@googlegroups.com
I think...and I might be wrong because I'm a little sleep deprived
today, that it seems like you just said the same thing twice...

Doug.
Reply all
Reply to author
Forward
0 new messages