-
Prefer
require
tobefore
. -
Don't break encapsulation. In particular, a resource within one module should not create a dependency (require or notify) to a resource deep within another. For example,
File[/etc/nginx/sites-available/foo]
from modulefoo
should not directly notifyService[nginx]
in modulenginx
. Instead consider these options: -
use
contain
in modules to ensure dependencies are inherited to contained classes correctly, and specify the dependency at the top level. In our example, this means we would have:class {'foo': notify => Class['nginx']} class {'nginx':}
-
create a defined type within one module which other modules can use which will set up the correct dependencies. See
nginx::config::site
for an example -- this is a defined type which allows other modules to create an nginx configuration and will make sure it happens afternginx::package
and beforenginx::service
, without the other module even knowing the existence of these classes. -
When a class includes or instantiates another class, consider whether you should use
contain
instead ofinclude
orclass
. See the Puppet documentation. If classa
contains classb
then any resource relationships made to classa
also apply to classb
.
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.