Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
discussion about encapsulation in puppet
Browse files Browse the repository at this point in the history
  • Loading branch information
philandstuff committed Aug 23, 2012
1 parent 74b3b39 commit 48874fd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions puppet.md
Expand Up @@ -11,6 +11,24 @@
- Do not use `->` and `~>`, use `require`, `notify` or `subscribe`
instead.
- *Never* use `<-` or `<~`. (Lint will stop you, anyway.)
- Don't break encapsulation. In particular, a resource within one module
not create a dependency (require or notify) to a resource deep within
another. For example, File[/etc/nginx/sites-available/foo] from module
foo should *not* directly notify Service[nginx] in module nginx.
Instead consider these options:
- use the anchor pattern to ensure dependencies are passed up and down
the include hierarchy correctly, and specifiy 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 after
nginx::package and before nginx::service, without the other module
even knowing the existence of these classes.
- When a class includes or instantiates another class, consider
whether you need to use the anchor pattern (see below). In
particular, for a top-level class `foo` which includes
Expand Down

0 comments on commit 48874fd

Please sign in to comment.