Alan Sparks
2007-May-01 23:58 UTC
Setting variables for a "group of nodes" - how to approach?
Trying to learn Puppet, given a cfengine background. Am trying to understand the Puppet way of accomplishing the following: I have a lot of servers, that are organized into clusters (we call them silos). Each silo has a specific set of parameters (like IP addresses). I''d like to organize the silo information in some way that each server is associated with that information, and can use variable settings in templates. So, I was trying something like the following (which I know is wrong): class silo1 { $lo1addr = "1.2.3.4" $lo2addr = "1.2.3.5" } node server1 { include silo1 include silows } Where I would try to use the $lo1addr and $lo2addr variables in a template in a file directive in the silows class. It did not work, maybe because of scoping issues. What is the correct way of approaching the task of "inheriting" a set of shared configuration information across a set of nodes? Thanks for a push in the right direction. -Alan -- Alan Sparks, UNIX/Linux Systems Integration and Administration <asparks@doublesparks.net>
Luke Kanies
2007-May-02 16:59 UTC
Re: Setting variables for a "group of nodes" - how to approach?
On May 1, 2007, at 6:58 PM, Alan Sparks wrote:> > What is the correct way of approaching the task of "inheriting" a > set of > shared configuration information across a set of nodes? > Thanks for a push in the right direction.As of 0.22.4, you can get those variables with $silo1::lo1addr et al. You''ll have to copy them into the class that uses the template though, because the templates can''t look up variables in other scopes: class mytemplate { $lo1addr = $silo1::lo1addr ... } I have to say, though, this is maybe not the best design. Do other classes use those variables? If not, then why not just have them in the class that uses them? Is the point just to have the node pick the collection of variables? -- Measure with a micrometer. Mark with chalk. Cut with an axe. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Alan Sparks
2007-May-02 19:38 UTC
Re: Setting variables for a "group of nodes" - how to approach?
Luke Kanies wrote:> > I have to say, though, this is maybe not the best design. Do other > classes use those variables? If not, then why not just have them in > the class that uses them? Is the point just to have the node pick > the collection of variables? > >The point is basically, I have a set of servers. Some Web servers, some databases, some other. I wanted some way to collect information, such as some important IP addresses, that apply to the nodes associated with that "silo". There would be many silos, many nodes, but no overlaps. So I was trying to collect that information, associate it with various servers, and use other means (classes?) to apply webserver or database actions to them as appropriate. -Alan -- Alan Sparks, UNIX/Linux Systems Integration and Administration <asparks@doublesparks.net>
Luke Kanies
2007-May-03 16:57 UTC
Re: Setting variables for a "group of nodes" - how to approach?
On May 2, 2007, at 2:38 PM, Alan Sparks wrote:> The point is basically, I have a set of servers. Some Web servers, > some > databases, some other. I wanted some way to collect information, such > as some important IP addresses, that apply to the nodes associated > with > that "silo". There would be many silos, many nodes, but no overlaps. > So I was trying to collect that information, associate it with various > servers, and use other means (classes?) to apply webserver or database > actions to them as appropriate.I''m hoping to get the node classification stuff working soon, and you''ll have this ability then. Until then, you''ll have to get what you want with case statements in the top scope and overrides in subclasses. -- I believe that if it were left to artists to choose their own labels, most would choose none. -- Ben Shahn --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com