Use `before` or `require` in Puppet manifests? -
okay, started learning puppet , working through docs. see:
require
samebefore
subscribe
samenotify
obviously these added @ opposite sides of dependency relationship, point.
from code readability , maintainability aspect, using 1 (of each pair) better other? should use both maximum clarity or make maintenance cumbersome? thoughts?
either variant works equally fine. have concrete uses though.
- make intentions more clear
e.g.
exec { "initialize-footool": require => package["footool"] } file { "/etc/default/footool": before => exec["initialize-footool"] }
read more english requires on exec.
- build relations other resources don't know resource in question
e.g.
include apache exec { "apache2ctl graceful": require => package[apache] } # package inside class apache
the latter pretty bad practice though. found 1 of definite benefits lie in these metaparameters' ability target whole classes instead.
include apache exec { "apache2ctl graceful": require => class["apache"] } file { "/etc/default/apache2": before => class["apache"] }
people intent on limiting to, say, require
instead of ever using before
can resort syntax
class { "apache": require => file["/etc/default/apache2"] }
the community discourages class {} style declarations though, because
- it cannot used declare same class more once
- it imposes parse order issues when mixed
include
statements same class
Comments
Post a Comment