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? -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Mar 18, 2010 at 2:57 PM, Christopher Johnston <chjohnst@gmail.com> 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> > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. >-- Cheers, Daniel -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
> 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?there is subscribe/notify and require/before. The last 2 simply order resources and the first two either listen on events or fire events. this means that if a service requires a file, puppet will only ensure that the service is managed after the file. However if the service subscribes to the file the service will restart itself when the file fires an event on change. for further information have a look at http://docs.reductivelabs.com/references/stable/metaparameter.html cheers pete -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Mar 18, 2010 at 10:07 AM, Daniel Kerwin <daniel@linuxaddicted.de> wrote:> On Thu, Mar 18, 2010 at 2:57 PM, Christopher Johnston > <chjohnst@gmail.com> 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 puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ok, that helped a lot. I read the documentation which is helpful, but the way you described it here made it easier to understand the use cases. On Thu, Mar 18, 2010 at 10:10 AM, Peter Meier <peter.meier@immerda.ch>wrote:> 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? >> > > there is subscribe/notify and require/before. The last 2 simply order > resources and the first two either listen on events or fire events. > > this means that if a service requires a file, puppet will only ensure that > the service is managed after the file. However if the service subscribes to > the file the service will restart itself when the file fires an event on > change. > > for further information have a look at > http://docs.reductivelabs.com/references/stable/metaparameter.html > > cheers pete > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
> > 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.That should read "but subscribe adds the additional..."> > 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 puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
I keep writing these exec types to things like service <something> restart, sounds like I dont need them and could just use subscribe which will in effect do the same thing. exec { ''sssd-restart'': command => ''/sbin/service sssd restart'', refreshonly => true, require => File[''/etc/sssd/sssd.conf''] } It sounds like I just need to make my server subscribe to the file and eliminate the exec. -Chris On Thu, Mar 18, 2010 at 10:11 AM, Michael DeHaan <michael@reductivelabs.com>wrote:> On Thu, Mar 18, 2010 at 10:07 AM, Daniel Kerwin <daniel@linuxaddicted.de> > wrote: > > On Thu, Mar 18, 2010 at 2:57 PM, Christopher Johnston > > <chjohnst@gmail.com> 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 puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thu, Mar 18, 2010 at 10:21 AM, Christopher Johnston <chjohnst@gmail.com> wrote:> I keep writing these exec types to things like service <something> restart, > sounds like I dont need them and could just use subscribe which will in > effect do the same thing. > exec { ''sssd-restart'': > command => ''/sbin/service sssd restart'', > refreshonly => true, > require => File[''/etc/sssd/sssd.conf''] > } > It sounds like I just need to make my server subscribe to the file and > eliminate the exec. > -Chris >Exactly. It looks like this: package {''ntp'': ensure => present } file {''/etc/ntp.conf'': owner => ''root'', group => ''root'', mode => ''644'', source => ''/etc/puppet/files/ntp/ntp.conf'', require => Package[''ntp''], } service {''ntpd'': enable => true, ensure => running, subscribe => File[''/etc/ntp.conf''], } --Michael -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
This answered all my questions, thx! Should hopefully clean up my manifests a bit those execs were overkill. On Thu, Mar 18, 2010 at 11:51 AM, Michael DeHaan <michael@reductivelabs.com>wrote:> On Thu, Mar 18, 2010 at 10:21 AM, Christopher Johnston > <chjohnst@gmail.com> wrote: > > I keep writing these exec types to things like service <something> > restart, > > sounds like I dont need them and could just use subscribe which will in > > effect do the same thing. > > exec { ''sssd-restart'': > > command => ''/sbin/service sssd restart'', > > refreshonly => true, > > require => File[''/etc/sssd/sssd.conf''] > > } > > It sounds like I just need to make my server subscribe to the file and > > eliminate the exec. > > -Chris > > > > Exactly. > > It looks like this: > > package {''ntp'': ensure => present } > file {''/etc/ntp.conf'': > owner => ''root'', > group => ''root'', > mode => ''644'', > source => ''/etc/puppet/files/ntp/ntp.conf'', > require => Package[''ntp''], > } > service {''ntpd'': > enable => true, > ensure => running, > subscribe => File[''/etc/ntp.conf''], > } > > --Michael > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.