Martijn Grendelman
2011-Nov-17 10:51 UTC
[Puppet Users] Exported resources: how to avoid duplicate definitions?
Hi, Is there a way to ''unique-ify'' a collection of resources? Suppose that nodes export ''@@nagios_hostgroup'' resources for hostgroups that they want to be a member of. The Nagios server node collect those: Nagios_hostgroup <<||>> But many nodes export the same hostgroups, because the whole point of having hostgroups is, that multiple hosts can be a member :-) So, the collection would lead to duplicate definitions. Is there a way to avoid that? Best regards, Martijn Grendelman -- 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.
Martijn Grendelman
2011-Nov-17 16:39 UTC
Re: [Puppet Users] Exported resources: how to avoid duplicate definitions?
On 17-11-11 11:51, Martijn Grendelman wrote:> Hi, > > Is there a way to ''unique-ify'' a collection of resources? > > Suppose that nodes export ''@@nagios_hostgroup'' resources for hostgroups > that they want to be a member of. The Nagios server node collect those: > > Nagios_hostgroup <<||>> > > But many nodes export the same hostgroups, because the whole point of > having hostgroups is, that multiple hosts can be a member :-) So, the > collection would lead to duplicate definitions. Is there a way to avoid that?By Googling a bit, and reading some old stuff from the list, I got the impression that it might be possible to just collect all those resources without problems. So I set up a simple test case: class testexport { @@file {"/tmp/blub": content => "fiep\n", } } class testcollect { File <<| tag == "testexport" |>> } node serverA { include testexport } node serverB { include testexport } node serverC { include testcollect } As expected, on serverC, this leads to the following error: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Exported resource File[/tmp/blub] cannot override local resource on node serverC Is there a way around this? Best regards, Martijn Grendelman -- 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.
Sunny
2012-Jan-06 09:13 UTC
[Puppet Users] Re: Exported resources: how to avoid duplicate definitions?
I too am facing the same issue. I am deploying my infrastructure in AWS cloud. err: Could not retrieve catalog from remote server: Error 400 on SERVER: Exported resource Nagios_hostgroup[cluster_pm] cannot override local resource on node ip-10-172-65-64.us-west-1.compute.internal Does anybody know how to avoid this duplicate definitions. hosts and hostgroups need to defined separately. Thanks On Nov 17 2011, 9:39 pm, Martijn Grendelman <mart...@iphion.nl> wrote:> On 17-11-11 11:51, Martijn Grendelman wrote: > > > Hi, > > > Is there a way to ''unique-ify'' a collection of resources? > > > Suppose that nodes export ''@@nagios_hostgroup'' resources for hostgroups > > that they want to be a member of. The Nagios server node collect those: > > > Nagios_hostgroup <<||>> > > > But many nodes export the same hostgroups, because the whole point of > > having hostgroups is, that multiple hosts can be a member :-) So, the > > collection would lead to duplicate definitions. Is there a way to avoid that? > > By Googling a bit, and reading some old stuff from the list, I got the > impression that it might be possible to just collect all those resources > without problems. So I set up a simple test case: > > class testexport { > > @@file {"/tmp/blub": > content => "fiep\n", > } > > } > > class testcollect { > File <<| tag == "testexport" |>> > > } > > node serverA { > include testexport > > } > > node serverB { > include testexport > > } > > node serverC { > include testcollect > > } > > As expected, on serverC, this leads to the following error: > > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > Exported resource File[/tmp/blub] cannot override local resource on node > serverC > > Is there a way around this? > > Best regards, > Martijn Grendelman-- 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.
windowsrefund
2012-Jan-06 16:55 UTC
[Puppet Users] Re: Exported resources: how to avoid duplicate definitions?
On Nov 17 2011, 5:51 am, Martijn Grendelman <mart...@iphion.nl> wrote:> Hi, > > Is there a way to ''unique-ify'' a collection of resources? > > Suppose that nodes export ''@@nagios_hostgroup'' resources for hostgroups > that they want to be a member of. The Nagios server node collect those: > > Nagios_hostgroup <<||>> > > But many nodes export the same hostgroups, because the whole point of > having hostgroups is, that multiple hosts can be a member :-) So, the > collection would lead to duplicate definitions. Is there a way to avoid that?The trick here is to realize that only the nagios server (the resource collector) needs access to these resources. This means your clients really do not need to export the resource at all. Instead, the resources should be included in the manifest that ends up being compiled by your nagios server(s). You''re probably saying "Yes, but how do I then control what hostgroup each client is a member of?". I solve this problem with a combination of a node scoped variable and the hostgroups parameter of the Nagios_host exported resource like so: @@nagios_host { hostgroups => inline_template("<%= has_variable? (''my_nagios_hostgroups'') ? my_nagios_hostgroups : ''Other'' %>"), ... and of course, my nagios server''s manifest then includes the hostgroup resources nagios_hostgroup { [''Awesome'', ''Not Awesome'', ''Other'']: ensure => present, ... } Best, Adam -- 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.