Hi all, We''ve been using Puppet to write out our Nagios configs for ages. I think I understand it pretty well. Recently we''ve had reason to set ''target'' on all Nagios resources, based on the fqdn of the monitored host. However I don''t want to have to set ''target'' by hand on all Nagios resources (nor remember to set it on all future ones). So my question is: what''s the easiest way to bulk-set the ''target'' parameter according to the fqdn? So far I tried setting it on the Nagios server, which didn''t work because $::fqdn is always the name of the Nagios server, not the monitored host Nagios_host <<| |>> { notify => Service[''nagios''], target => "/etc/nagios/conf.d/${::fqdn}.cfg", } I also tried including this on the monitored host, which didn''t work because it attempts to realise all Nagios_host resources on the monitored host, not the Nagios server. Nagios_host <<| |>> { target => "/etc/nagios/conf.d/${::fqdn}.cfg", } Is there an easy way to easily making all nagios_* resources have a fqdn-specific target? Thanks, Jonathan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Jonathan, You would want to do it on the client level, when its exporting its host definition, like: @@nagios_host { $hostname: ensure => present, alias => $hostname, address => $ipaddress, use => $template, hostgroups => $hostgroups, notes => "$manufacturer $productname", target => "/etc/nagios/conf.d/puppet/$hostname.cfg", } etc. On Mon, Jul 22, 2013 at 10:08 AM, Jonathan Gazeley < Jonathan.Gazeley@bristol.ac.uk> wrote:> Hi all, > > We''ve been using Puppet to write out our Nagios configs for ages. I think > I understand it pretty well. Recently we''ve had reason to set ''target'' on > all Nagios resources, based on the fqdn of the monitored host. However I > don''t want to have to set ''target'' by hand on all Nagios resources (nor > remember to set it on all future ones). > > So my question is: what''s the easiest way to bulk-set the ''target'' > parameter according to the fqdn? > > So far I tried setting it on the Nagios server, which didn''t work because > $::fqdn is always the name of the Nagios server, not the monitored host > > Nagios_host <<| |>> { > notify => Service[''nagios''], > target => "/etc/nagios/conf.d/${::fqdn}.**cfg", > } > > I also tried including this on the monitored host, which didn''t work > because it attempts to realise all Nagios_host resources on the monitored > host, not the Nagios server. > > Nagios_host <<| |>> { target => "/etc/nagios/conf.d/${::fqdn}.**cfg", } > > Is there an easy way to easily making all nagios_* resources have a > fqdn-specific target? > > Thanks, > Jonathan > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@**googlegroups.com<puppet-users%2Bunsubscribe@googlegroups.com> > . > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/**group/puppet-users<http://groups.google.com/group/puppet-users> > . > For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> > . > > >-- Matthew Nicholson -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
On 23 July 2013 02:47, Matthew Nicholson <matthew.a.nicholson@gmail.com> wrote:> Jonathan, > > You would want to do it on the client level, when its exporting its host > definition, like: > > @@nagios_host { $hostname: > ensure => present, > alias => $hostname, > address => $ipaddress, > use => $template, > hostgroups => $hostgroups, > notes => "$manufacturer $productname", > target => "/etc/nagios/conf.d/puppet/$hostname.cfg", > }I find it best to not use a target for the nagios resources. The provider is only able to delete them if you use the default locations.> > etc. > > > On Mon, Jul 22, 2013 at 10:08 AM, Jonathan Gazeley > <Jonathan.Gazeley@bristol.ac.uk> wrote: >> >> Hi all, >> >> We''ve been using Puppet to write out our Nagios configs for ages. I think >> I understand it pretty well. Recently we''ve had reason to set ''target'' on >> all Nagios resources, based on the fqdn of the monitored host. However I >> don''t want to have to set ''target'' by hand on all Nagios resources (nor >> remember to set it on all future ones). >> >> So my question is: what''s the easiest way to bulk-set the ''target'' >> parameter according to the fqdn? >> >> So far I tried setting it on the Nagios server, which didn''t work because >> $::fqdn is always the name of the Nagios server, not the monitored host >> >> Nagios_host <<| |>> { >> notify => Service[''nagios''], >> target => "/etc/nagios/conf.d/${::fqdn}.cfg", >> } >> >> I also tried including this on the monitored host, which didn''t work >> because it attempts to realise all Nagios_host resources on the monitored >> host, not the Nagios server. >> >> Nagios_host <<| |>> { target => "/etc/nagios/conf.d/${::fqdn}.cfg", } >> >> Is there an easy way to easily making all nagios_* resources have a >> fqdn-specific target? >> >> Thanks, >> Jonathan >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Puppet Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to puppet-users+unsubscribe@googlegroups.com. >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > > > -- > Matthew Nicholson > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
Hi Matthew, Thanks for your response. I know your approach will work, but I''m reluctant to go through my manifests and change every reference to nagios_* to include a ''target'' parameter. It''s not only an effort to change now, but I also have to remember to add a ''target'' every time I add Nagios resources in future. That''s why I was asking if there was a way to bulk-apply the ''target'' parameter, either client-side or server-side. If not then I''ll have to do it this way :) Cheers, Jonathan On 22/07/13 17:47, Matthew Nicholson wrote:> Jonathan, > > You would want to do it on the client level, when its exporting its > host definition, like: > > @@nagios_host { $hostname: > ensure => present, > alias => $hostname, > address => $ipaddress, > use => $template, > hostgroups => $hostgroups, > notes => "$manufacturer $productname", > target => "/etc/nagios/conf.d/puppet/$hostname.cfg", > } > > etc. > > > On Mon, Jul 22, 2013 at 10:08 AM, Jonathan Gazeley > <Jonathan.Gazeley@bristol.ac.uk > <mailto:Jonathan.Gazeley@bristol.ac.uk>> wrote: > > Hi all, > > We''ve been using Puppet to write out our Nagios configs for ages. > I think I understand it pretty well. Recently we''ve had reason to > set ''target'' on all Nagios resources, based on the fqdn of the > monitored host. However I don''t want to have to set ''target'' by > hand on all Nagios resources (nor remember to set it on all future > ones). > > So my question is: what''s the easiest way to bulk-set the ''target'' > parameter according to the fqdn? > > So far I tried setting it on the Nagios server, which didn''t work > because $::fqdn is always the name of the Nagios server, not the > monitored host > > Nagios_host <<| |>> { > notify => Service[''nagios''], > target => "/etc/nagios/conf.d/${::fqdn}.cfg", > } > > I also tried including this on the monitored host, which didn''t > work because it attempts to realise all Nagios_host resources on > the monitored host, not the Nagios server. > > Nagios_host <<| |>> { target => "/etc/nagios/conf.d/${::fqdn}.cfg", } > > Is there an easy way to easily making all nagios_* resources have > a fqdn-specific target? > > Thanks, > Jonathan > > -- > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, > send an email to puppet-users+unsubscribe@googlegroups.com > <mailto:puppet-users%2Bunsubscribe@googlegroups.com>. > To post to this group, send email to puppet-users@googlegroups.com > <mailto:puppet-users@googlegroups.com>. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > Matthew Nicholson > -- > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
On 23/07/13 02:50, Pete Brown wrote:> I find it best to not use a target for the nagios resources. > The provider is only able to delete them if you use the default locations.Yes, I''m aware of the limitations and have avoided setting the target until now. Unfortunately our Nagios config is so large that it takes a looong time to parse it, so I want to split it out to one config file per host, for ease of parsing. It will become part of our decommissioning process to delete the host''s Nagios file as well as removing DNS records, deleting the VM, etc. Cheers, Jonathan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.
You can set Nagios_host { target => "/etc/nagios/conf.d/${::fqdn}.cfg", } somewhere in site.pp file; just make sure it is in the global scope. This is just defining a default parameter for the resource. Note that this is a bad practice as everything global -- Nikola On Mon, Jul 22, 2013 at 03:08:49PM +0100, Jonathan Gazeley wrote:> Hi all, > > We''ve been using Puppet to write out our Nagios configs for ages. I > think I understand it pretty well. Recently we''ve had reason to set > ''target'' on all Nagios resources, based on the fqdn of the monitored > host. However I don''t want to have to set ''target'' by hand on all > Nagios resources (nor remember to set it on all future ones). > > So my question is: what''s the easiest way to bulk-set the ''target'' > parameter according to the fqdn? > > So far I tried setting it on the Nagios server, which didn''t work > because $::fqdn is always the name of the Nagios server, not the > monitored host > > Nagios_host <<| |>> { > notify => Service[''nagios''], > target => "/etc/nagios/conf.d/${::fqdn}.cfg", > } > > I also tried including this on the monitored host, which didn''t work > because it attempts to realise all Nagios_host resources on the > monitored host, not the Nagios server. > > Nagios_host <<| |>> { target => "/etc/nagios/conf.d/${::fqdn}.cfg", } > > Is there an easy way to easily making all nagios_* resources have a > fqdn-specific target? > > Thanks, > Jonathan > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users. For more options, visit https://groups.google.com/groups/opt_out.