Here http://ttboj.wordpress.com/2013/06/04/collecting-duplicate-resources-in-puppet/ is explained how to do the "trick" to be allowed to define several times the same exported resource.
The basic idea is: - Create a custom defined type to be exported - That defined type should be exported always with different names ($fqdn for instance) - Inside that defined type, use ensure_resource() to create the needed resource (this method will create only one resource, no matter how many times is defined) I have implemented my own solution: https://github.com/adrianlzt/puppet-monitoring/blob/feature/default_hostgroup/puppetmasterData/modules/monitorizacion/manifests/basic.pp lines 28-33 https://github.com/adrianlzt/puppet-monitoring/blob/feature/default_hostgroup/puppetmasterData/modules/monitorizacion/manifests/icinga/hostgroup.pp lines 12-23 https://github.com/adrianlzt/puppet-monitoring/blob/feature/default_hostgroup/puppetmasterData/modules/monitorizacion/manifests/icinga.pp lines 133-136 El viernes, 6 de enero de 2012 17:55:11 UTC+1, windowsrefund escribió: > > > > On Nov 17 2011, 5:51 am, Martijn Grendelman <[email protected]> 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/452c4488-a7a7-4b1a-846a-ddb4dff5fbdd%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
