On Thu, Mar 18, 2010 at 10:07 AM, Daniel Kerwin <[email protected]> wrote: > On Thu, Mar 18, 2010 at 2:57 PM, Christopher Johnston > <[email protected]> wrote: >> Can some help explain the differences and use cases of subscribe and >> require. They seem to have a bit overlap in the sense that they do the same >> thing almost. I understand a require sets up a dependency. So for eg the >> following below would setup a dependency on the package pam to be installed >> in order for the file type to run. >> package { 'pam': >> ensure = > latest, >> } >> file { '/etc/pam.d/system-auth': >> ensure => symlink, >> target => 'system-auth-ac', >> require => Package['pam'] >> } >> But what I am confused about is how is subscribe different? Doesn't that >> handle the same relationship of saying that you are "subscribing" (and/or) >> requiring something? > > Subscribe and notify are responsible for notifying resources of > changes in another resource. For example: > > file { "/etc/apache2/httpd.conf"; > ... > require => Package["apache"], > notify => Service["apache"], > } > > The require statement ensures that the package apache is installed > before the file is managed. When the file httpd.conf is updated the > service apache is notified to restart/reload. > > Hope this helps >
To put it another way, subscribe is a special case of require with added magic in it. They both imply the same ordering relationship, but require adds the additional 'restart if this is changed' logic. Similarly, notify is like before, with that same extra magic, just specified in a different way. It does the same thing. You could write all of your Puppet language with 'subscribe' and 'require' instead of 'notify' and 'before' if it made it simpler for you. You can think of 'require' as reading like 'after'. --Michael -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
