Duncan Hill
2009-Aug-19 15:03 UTC
[Puppet Users] Conditional host file entries, Puppet''s non-sequential tree
Hello folks, Running 0.24.6, and I need a clue-by-4 with something I''m trying to do. I have a single manifest file, used by 3 servers. Depending on the server name, I need to allocate a different set of variables that get used to populate a host {} block. Since Puppet doesn''t work in a top-down manner, this has a chance of working sometimes, but not all the time. A convoluted approach that just came to mind is to use inheritance tricks. Namely: node application-server inherits generic-server { all common stuff other than hosts possibly the if logic to set the IPs } node specific-1 inherits application-server { host {} } node specific-2 inherits application-server { host {} } Are there any better solutions to this? I''m making the assumption (that I''m about to test) that inheritance is top-down. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Duncan Hill
2009-Aug-20 11:17 UTC
[Puppet Users] Re: Conditional host file entries, Puppet''s non-sequential tree
On Aug 19, 4:03 pm, Duncan Hill <bajand...@googlemail.com> wrote:> Hello folks, > > node application-server inherits generic-server { > all common stuff other than hosts > possibly the if logic to set the IPs} > > node specific-1 inherits application-server { > host {}} > > node specific-2 inherits application-server { > host {} > > } > > Are there any better solutions to this? I''m making the assumption > (that I''m about to test) that inheritance is top-down.Turns out this doesn''t work either. Bummer. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Larry Ludwig
2009-Aug-20 13:18 UTC
[Puppet Users] Re: Conditional host file entries, Puppet''s non-sequential tree
On Aug 19, 2009, at 11:03 AM, Duncan Hill wrote:> > Hello folks, > > Running 0.24.6, and I need a clue-by-4 with something I''m trying to > do. > > I have a single manifest file, used by 3 servers. Depending on the > server name, I need to allocate a different set of variables that get > used to populate a host {} block. > > Since Puppet doesn''t work in a top-down manner, this has a chance of > working sometimes, but not all the time. > > A convoluted approach that just came to mind is to use inheritance > tricks. Namely: > > node application-server inherits generic-server { > all common stuff other than hosts > possibly the if logic to set the IPs > } > node specific-1 inherits application-server { > host {} > } > node specific-2 inherits application-server { > host {} > } > > Are there any better solutions to this? I''m making the assumption > (that I''m about to test) that inheritance is top-down.Hi Duncan, why not define the variables per ''node''? Why use inheritance at all? Personally I''m not a fan of node inheritance and like putting all of the classes in another class which then is in included in each node. For your example, create a class and specify the ''host'' type. If these are required parameters, you can put in your ''class'' something like this: case $directadmin_cid { '''': { fail("You need to define your directadmin cid! Please set \$directadmin_cid in your site.pp or node config") } } This will make sure that the node has the proper variables when you include the class. Hope this helps... -L -- Larry Ludwig Reductive Labs --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Duncan Hill
2009-Aug-21 14:03 UTC
[Puppet Users] Re: Conditional host file entries, Puppet''s non-sequential tree
2009/8/20 Larry Ludwig <larry@reductivelabs.com>:> > > On Aug 19, 2009, at 11:03 AM, Duncan Hill wrote: > > why not define the variables per ''node''? Why use inheritance at all? > Personally I''m not a fan of node inheritance and like putting all of > the classes in another class which then is in included in each node.I can do this, it just amplifies my work rather than reducing it. The scenario is multiple stacks of ''identical'' servers - Glassfish, Tomcat, Postgres. All of them have identical host files in terms of names that are aliased to the IP addresses, it''s just the addresses that change. (Basically, umpteen development or QA environments in VMware, all configured the same barring the IPs that the symbolic names point to.) So each node needs to define a set of IP addresses in variables, and I just change the block of variables for each server, conditional on the hostname, generating custom host addresses. Well, that was the theory at least. I''ve tried the approach of node foo { $ip1 = 1.1.1.1 $ip2 = 2.2.2.2 include host_definitions } class host_definitions { host { ''fred'': { ip => $ip1, alias => [ a, b, c ] } } } and more often than not I get an error that $ip1 isn''t defined, and puppet falls over in a heap. Inheritance has been useful for me, but I am actually moving a lot of code over to class/module based (as and when I can; the current system works, and I have enough keeping me busy that rewriting it isn''t high on the list). Cheers. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Duncan Hill
2009-Aug-22 10:04 UTC
[Puppet Users] Re: Conditional host file entries, Puppet''s non-sequential tree
2009/8/21 Duncan Hill <bajandude@googlemail.com>:> 2009/8/20 Larry Ludwig <larry@reductivelabs.com>: >> >> >> On Aug 19, 2009, at 11:03 AM, Duncan Hill wrote: >> >> why not define the variables per ''node''? Why use inheritance at all? >> Personally I''m not a fan of node inheritance and like putting all of >> the classes in another class which then is in included in each node.> node foo { > $ip1 = 1.1.1.1 > $ip2 = 2.2.2.2 > > include host_definitions > } > > class host_definitions { > host { > ''fred'': { ip => $ip1, alias => [ a, b, c ] } > } > } > > and more often than not I get an error that $ip1 isn''t defined, and > puppet falls over in a heap.Well, now it works. So I''ll spend the weekend refactoring my setup to behave in this manner, and hopefully lots of problems will go away. Thanks Larry. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Larry Ludwig
2009-Aug-22 16:59 UTC
[Puppet Users] Re: Conditional host file entries, Puppet''s non-sequential tree
On Aug 22, 2009, at 6:04 AM, Duncan Hill wrote:> > 2009/8/21 Duncan Hill <bajandude@googlemail.com>: >> 2009/8/20 Larry Ludwig <larry@reductivelabs.com>: >>> >>> >>> On Aug 19, 2009, at 11:03 AM, Duncan Hill wrote: >>> >>> why not define the variables per ''node''? Why use inheritance at >>> all? >>> Personally I''m not a fan of node inheritance and like putting all of >>> the classes in another class which then is in included in each node. > >> node foo { >> $ip1 = 1.1.1.1 >> $ip2 = 2.2.2.2 >> >> include host_definitions >> } >> >> class host_definitions { >> host { >> ''fred'': { ip => $ip1, alias => [ a, b, c ] } >> } >> } >> >> and more often than not I get an error that $ip1 isn''t defined, and >> puppet falls over in a heap. > > Well, now it works. So I''ll spend the weekend refactoring my setup to > behave in this manner, and hopefully lots of problems will go away. > Thanks Larry.No problem. You will find this methodology works well with external nodes. -L -- Larry Ludwig Reductive Labs --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---