Either variant works equally fine. They have some 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 like english than just requires on the exec.
- Build relations to other resources that don't know about the resource in question
E.g.
include apache
exec { "apache2ctl graceful": require => Package[apache] } # package inside class apache
The latter is pretty bad practice though. I found that one of the most definite benefits lie in these metaparameters' ability to target whole classes instead.
include apache
exec { "apache2ctl graceful": require => Class["apache"] }
file { "/etc/default/apache2": before => Class["apache"] }
People who are intent on limiting themselves to, say, require
instead of ever using before
can resort to this syntax
class { "apache": require => File["/etc/default/apache2"] }
The community discourages class {} style declarations though, because
- it cannot be used to declare the same class more than once
- it imposes parse order issues even when mixed with
include
statements for the same class