Grant Byers
2011-Nov-30 09:22 UTC
[Puppet Users] Using facts from stored configs based on class
Hi, Is it possible to use facts from external nodes via stored configs, based on a filter such as class? To illustrate, I provide the following use case ; class nagios::nrpe { # No such resource "ip". I''d like to use "ip" fact of any node that is assigned to class "nagios::server" $nagios_servers = Ip <<| class="nagios::server" |>> # Construct firewall rule from template using knowledge of external hosts. ipt_fragment { "090nrpe_filter": table => "filter", content => template("nagios/nrpe.cfg.erb"), } } templates/nrpe.cfg.erb: ... allowed_hosts=<%= nagios_servers.join('','') %> ... I''m currently storing this type of data (nagios_servers) in CSV & using extlookup, but it seems to me that we should already know this information if we''re using stored configs. Thanks, Grant -- 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-Dec-02 13:56 UTC
[Puppet Users] Re: Using facts from stored configs based on class
On Nov 30, 3:22 am, Grant Byers <grant.by...@gmail.com> wrote:> Hi, > > Is it possible to use facts from external nodes via stored configs, based > on a filter such as class? To illustrate, I provide the following use case ; > > class nagios::nrpe { > # No such resource "ip". I''d like to use "ip" fact of any node that is > assigned to class "nagios::server" > $nagios_servers = Ip <<| class="nagios::server" |>> > > # Construct firewall rule from template using knowledge of external hosts. > ipt_fragment { "090nrpe_filter": > table => "filter", > content => template("nagios/nrpe.cfg.erb"), > } > > } > > templates/nrpe.cfg.erb: > ... > allowed_hosts=<%= nagios_servers.join('','') %> > ... > > I''m currently storing this type of data (nagios_servers) in CSV & using > extlookup, but it seems to me that we should already know this information > if we''re using stored configs.You cannot collect nodes'' facts, only their exported resources. The way to approach your problem with storeconfigs is for each node of interest to export an appropriate resource (perhaps an ipt_fragment, for example), which can then all be collected. Note that the resource titles must all be different. If that''s not good for you, then you''ll need to rethink your design concept. Perhaps you can come up with a central data source (could be as simple as a Puppet array or hash) by which you can drive both whether individual nodes get class ''nagios::server'' and the rules set up by class ''nagios::nrpe''. 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.