Hello all I work at a company using Puppet. Our configuration requires that one node needs information about (all) the other nodes (which are the backup servers, what is their IP, building firewall rules, DNS, ...). So I have an array of all the nodes with their IP(''s): $nodes = [ "fqdn/192.168.1.1", "fqdn/192.168.1.2:192.168.1.3", ... ] This way, I can use a template and .split all the information I need. We also use pools of servers, and a server can change from pool. For example, instead of writing "include web01" for each node that is a webserver in pool 01, I write: $web01_nodes = [ "fqdn", "fqdn", ... ] And every node includes a template class that will check if the node is in this array or not, and includes the appropriate class(es). This makes it easier for doing modifications and having an overview of all the nodes. I made a function to do this: module Puppet::Parser::Functions newfunction(:is_node_in_array, :type => :rvalue) do |args| result = false args[0].each do |node| if node == lookupvar(''fqdn'') result = true break end end result end end Could I get some feedback about this approach? Is something like this possible without the custom function? Is someone doing this on a better way? It looks like they are not many functions to work with arrays. Thanks, kind regards Wout --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Wout wrote:> Could I get some feedback about this approach? Is something like this > possible without the custom function? Is someone doing this on a > better > way? It looks like they are not many functions to work with arrays.While it may be quite an initial implementation hump, it will probably save you many headaches down the line if you look into using an external node classifier. There you can maintain your system''s and architecture''s information in a format of your choosing and prepare the data for puppet''s consumption on a need-to-know basis. See the wiki for more information: http://reductivelabs.com/trac/puppet/wiki/ExternalNodes Regards, DavidS --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 8, 10:38 am, David Schmitt <da...@dasz.at> wrote:> While it may be quite an initial implementation hump, it will probably > save you many headaches down the line if you look into using an external > node classifier. There you can maintain your system''s and architecture''s > information in a format of your choosing and prepare the data for > puppet''s consumption on a need-to-know basis. > > See the wiki for more information:http://reductivelabs.com/trac/puppet/wiki/ExternalNodesThanks for the fast reply :) Creating a shell script to produce a YAML output with (only) the information that node needs looks very interesting. Too bad you cannot define resources for a specific node, but I do not think this will be necessary in my setup. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Wout wrote:> On Oct 8, 10:38 am, David Schmitt <da...@dasz.at> wrote: >> While it may be quite an initial implementation hump, it will probably >> save you many headaches down the line if you look into using an external >> node classifier. There you can maintain your system''s and architecture''s >> information in a format of your choosing and prepare the data for >> puppet''s consumption on a need-to-know basis. >> >> See the wiki for more information:http://reductivelabs.com/trac/puppet/wiki/ExternalNodes > > Thanks for the fast reply :) Creating a shell script to produce a YAML > output with (only) the information that node needs looks very > interesting. Too bad you cannot define resources for a specific node, > but I do not think this will be necessary in my setup.This is a common "problem" with external nodes, but that can mostly be worked around by including the hostname as class and using that to include manual overrides. If you need even more dynamic stuff, get Volcane''s extlookup() function: http://nephilim.ml.org/~rip/puppet/extlookup.rb Regards, DavidS --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---