Hello list, I have a situation where if I have a hosts file generated by exported resources it does not trigger a service restart unlike if it was subscribing on a file that gets copied over via puppet. An example would explain it better. it should be noted that exported resources work fine. class dnsmasq { file { "/etc/hosts": owner => "root", group => "root", mode => "644", source => "puppet:///modules/dnsmasq/hosts", } ... service { dnsmasq: ensure => running, enable => true, pattern => "dnsmasq", subscribe => File["/etc/dnsmasq.conf","/etc/dnsmasq- local.conf","/etc/hosts"], hasrestart => true, } So with the above if i change the file on the master then it will push out to all hosts that include the dnsmasq class and restart the dnsmasq service, all is good. How ever if I generate the data using exported resources nothing happens Below doesn''t work class dnsmasq { Host<<| tag == "all_hosts" |>> service { dnsmasq: ensure => running, enable => true, pattern => "dnsmasq", subscribe => File["/etc/dnsmasq.conf","/etc/dnsmasq- local.conf","/etc/hosts"], hasrestart => true, } } // seperate class with /etc/hosts defined class hosts { file { "/etc/hosts": owner => "root", group => "root", mode => "644", } host { ''localhost'': ip => ''127.0.0.1'', host_aliases => ''localhost.localdomain'', } ... a few default hosts... } So my issue is that on all machines the hosts files are managed fine, however on my internal dns servers that collect all the IPs of all machines in the network whilst collecting the hosts files fine, the dnsmasq service is never restarted, meaning i need to log into each machine and manually restart dnsmasq to pick up the changes after a new host is added to the system. Any ideas? Thanks Nathan -- 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.
Greg Sutcliffe
2011-May-06 09:19 UTC
[Puppet Users] Re: issue with exported resources and subscribe
Hi, In my exported resource manifests, if using code like: File <<| tag == "nagios::target" |>> { notify => Service["nagios3"] } Does that work for you? Cheers, Greg -- 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.
jcbollinger
2011-May-06 13:41 UTC
[Puppet Users] Re: issue with exported resources and subscribe
On May 5, 1:00 am, Nathan <pheni...@gmail.com> wrote:> Hello list, > > I have a situation where if I have a hosts file generated by exported > resources it does not trigger a service restart unlike if it was > subscribing on a file that gets copied over via puppet. An example > would explain it better. > > it should be noted that exported resources work fine. > > class dnsmasq { > file { "/etc/hosts": > owner => "root", > group => "root", > mode => "644", > source => "puppet:///modules/dnsmasq/hosts", > } > > ... > > service { dnsmasq: > ensure => running, > enable => true, > pattern => "dnsmasq", > subscribe => File["/etc/dnsmasq.conf","/etc/dnsmasq- > local.conf","/etc/hosts"], > hasrestart => true, > } > > So with the above if i change the file on the master then it will push > out to all hosts that include the dnsmasq class and restart the > dnsmasq service, all is good. > > How ever if I generate the data using exported resources nothing > happens > > Below doesn''t work > > class dnsmasq { > Host<<| tag == "all_hosts" |>> > > service { dnsmasq: > ensure => running, > enable => true, > pattern => "dnsmasq", > subscribe => File["/etc/dnsmasq.conf","/etc/dnsmasq- > local.conf","/etc/hosts"], > hasrestart => true, > } > > } > > // seperate class with /etc/hosts defined > class hosts { > file { "/etc/hosts": > owner => "root", > group => "root", > mode => "644", > } > > host { ''localhost'': > ip => ''127.0.0.1'', > host_aliases => ''localhost.localdomain'', > } > ... a few default hosts... > > } > > So my issue is that on all machines the hosts files are managed fine, > however on my internal dns servers that collect all the IPs of all > machines in the network whilst collecting the hosts files fine, the > dnsmasq service is never restarted, meaning i need to log into each > machine and manually restart dnsmasq to pick up the changes after a > new host is added to the system. > > Any ideas?Yes. To get this sort of thing right, you need to think in terms of Puppet''s logical model of the managed system, as opposed to in terms of the observable result of Puppet''s work. In particular, as far as Puppet is concerned, managing file /etc/hosts via a File resource is logically distinct from managing entries in that file via Host resources. File["/etc/hosts"] will trigger subscribers if it itself needs to apply any changes, but it doesn''t know anything about Host resources. Indeed, it is possible that on some systems, Host resources do not physically manifest in that file. In your all-local example, File["/etc/hosts"] manages the content of the /etc/hosts file (source => ...), so it triggers Service["dnsmasq"] when that content changes. In your exported-resource example, File["/ etc/hosts"] manages only the existence, ownership, and mode of the file -- not its contents -- so it only notifies subscribers if one of those things is changed. You need Service["dnsmasq"] to subscribe to all the Host resources, or, as Greg suggested, you need the Host entries to notify the Service. John -- 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.
Nathan
2011-May-07 00:33 UTC
[Puppet Users] Re: issue with exported resources and subscribe
> > To get this sort of thing right, you need to think in terms of > Puppet''s logical model of the managed system, as opposed to in terms > of the observable result of Puppet''s work. In particular, as far as > Puppet is concerned, managing file /etc/hosts via a File resource is > logically distinct from managing entries in that file via Host > resources. File["/etc/hosts"] will trigger subscribers if it itself > needs to apply any changes, but it doesn''t know anything about Host > resources. Indeed, it is possible that on some systems, Host > resources do not physically manifest in that file. > > In your all-local example, File["/etc/hosts"] manages the content of > the /etc/hosts file (source => ...), so it triggers Service["dnsmasq"] > when that content changes. In your exported-resource example, File["/ > etc/hosts"] manages only the existence, ownership, and mode of the > file -- not its contents -- so it only notifies subscribers if one of > those things is changed. > > You need Service["dnsmasq"] to subscribe to all the Host resources, > or, as Greg suggested, you need the Host entries to notify the > Service. > > JohnJohn, Greg, Thanks for the tips, once I forced the hosts resources to notify the service all is working as intended, thanks! Nathan -- 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.