Hello, I''m somewhat new to puppetmaster, and just wanted to know an easier way to do the following: We have several clients, and some configuration needs to be done depending on which client''s network our server is in. We have already an environment variable telling us which client''s network the server is on, and I can also access it as a puppet fact ($client). Now what I tried to do was to load alll recipe files in network/$client, but that doesn''t seem to work. Only way I managed to do it for now was to add "include $client" in the node definition, to name all my different config classes in the form "client1_$someclass", and to create a class for each client where I include all my "client1_$someclass" classes. The problem with this solution is that I have to add each new puppet definition file as a define in the "master" client class. Is there any way I could have includes of all classes matching client1_* or of all classes that are defined in puppet files in some path or anything? Thanks, Felix Schäfer
puppet-users-bounces@madstop.com wrote on 06/02/2008 13:31:48:> > We have several clients, and some configuration needs to be done > depending on which client''s network our server is in. We have > already an environment variable telling us which client''s network > the server is on, and I can also access it as a puppet fact > ($client). Now what I tried to do was to load alll recipe files in > network/$client, but that doesn''t seem to work. Only way I managed > to do it for now was to add "include $client" in the node > definition, to name all my different config classes in the form > "client1_$someclass", and to create a class for each client where I > include all my "client1_$someclass" classes. > > The problem with this solution is that I have to add each new puppet > definition file as a define in the "master" client class. Is there > any way I could have includes of all classes matching client1_* or > of all classes that are defined in puppet files in some path oranything? Might a case statement somewhere be of help? eg case $client { "first.client": { include first_client_thing include common_thing include common_other } "second.client": { include second_client_thing include common_thing } "third.client": { include third_client_thing include common_other } etc etc. Matthew ------------------------------------------------------------------ Visit Guardian Unlimited - the UK''s most popular newspaper website http://guardian.co.uk http://observer.co.uk ------------------------------------------------------------------ The Newspaper Marketing Agency Opening Up Newspapers http://www.nmauk.co.uk ------------------------------------------------------------------ Please consider the environment before printing this email This e-mail and all attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender and delete the e-mail and all attachments immediately. Do not disclose the contents to another person. You may not use the information for any purpose, or store, or copy, it in any way. Guardian News & Media Limited is not liable for any computer viruses or other material transmitted with or as part of this e-mail. You should employ virus checking software. Guardian News & Media Limited A member of Guardian Media Group PLC Registered Office Number 1 Scott Place, Manchester M3 3GG Registered in England Number 908396
Felix Schäfer schrieb:> Hello, > > I''m somewhat new to puppetmaster, and just wanted to know an easier > way to do the following: > > We have several clients, and some configuration needs to be done > depending on which client''s network our server is in. We have already > an environment variable telling us which client''s network the server > is on, and I can also access it as a puppet fact ($client). Now what > I tried to do was to load alll recipe files in network/$client, but > that doesn''t seem to work. Only way I managed to do it for now was to > add "include $client" in the node definition, to name all my > different config classes in the form "client1_$someclass", and to > create a class for each client where I include all my > "client1_$someclass" classes. > > The problem with this solution is that I have to add each new puppet > definition file as a define in the "master" client class. Is there > any way I could have includes of all classes matching client1_* or of > all classes that are defined in puppet files in some path or > anything?It might help you to use globbing and namespaces: import "stuff/clients*/*.pp" node default { include $client::the_class include $client::the_other_class } Regards, DavidS
Hello Am Donnerstag, den 07.02.2008, 07:43 +0100 schrieb David Schmitt:> It might help you to use globbing and namespaces: > > import "stuff/clients*/*.pp" > > node default { > include $client::the_class > include $client::the_other_class > }Well, I do that already, or I wouldn't be able to call the classes at all :-) What I am looking for would rather be globbing for class names, e.g. being able to "include $client::*", so that I don't need to have all the same classes for all clients, or write a collection of classes for each client using some sort of switch/case. I tried different ideas to get globbing in includes, but I suppose the current puppet version just doesn't support it. If it's possible at all, I'd like to file it as a feature request, if not, I guess I'll just have to make do and find another way to make using puppet easier for me :-) Thanks for the help, Felix Schäfer _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
Felix Schäfer schrieb:> Hello > > Am Donnerstag, den 07.02.2008, 07:43 +0100 schrieb David Schmitt: >> It might help you to use globbing and namespaces: >> >> import "stuff/clients*/*.pp" >> >> node default { >> include $client::the_class >> include $client::the_other_class >> } > > Well, I do that already, or I wouldn't be able to call the classes at > all :-) What I am looking for would rather be globbing for class names, > e.g. being able to "include $client::*", so that I don't need to have > all the same classes for all clients, or write a collection of classes > for each client using some sort of switch/case. > > I tried different ideas to get globbing in includes, but I suppose the > current puppet version just doesn't support it. If it's possible at all, > I'd like to file it as a feature request, if not, I guess I'll just have > to make do and find another way to make using puppet easier for me :-)Well, you don't have to use classes. You'd need to use something like the modulepath and environment support[1] to split the configurations, as importing happens too early in the configuration process. Not what I would recommend. Alternatively, you might also want to take a look at external node support[2], which allows you to control class inclusion with a script that is called by the puppetmaster. Regards, David [1] http://reductivelabs.com/trac/puppet/wiki/UsingMultipleEnvironments [2] http://reductivelabs.com/trac/puppet/wiki/ExternalNodeClassification _______________________________________________ Puppet-users mailing list Puppet-users@madstop.com https://mail.madstop.com/mailman/listinfo/puppet-users
On Feb 7, 2008, at 4:23 AM, David Schmitt wrote:> Well, you don''t have to use classes. You''d need to use something like > the modulepath and environment support[1] to split the configurations, > as importing happens too early in the configuration process. Not > what I > would recommend.This will never work all that well; code inside of classes will always behave a bit more consistently than code outside of classes, at least when the files are autoloaded (because the parse time affects evaluation order).> > Alternatively, you might also want to take a look at external node > support[2], which allows you to control class inclusion with a script > that is called by the puppetmaster.This is *definitely* what I''d recommend. -- I never did give anybody hell. I just told the truth, and they thought it was hell. -- Harry S Truman --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com