Sylvain Mougenot
2013-Jan-30 10:52 UTC
[Puppet Users] Best practice to share variable values among nodes
Hello, I''m new to puppet using a puppet-master. And I couldn''t figure out what''s the best practice I need. *My context : * - puppet-master with a puppet dashboard is setup and running - few modules are ready and fully fonctionnal (tested using vagrant and "puppet apply") - there are some nodes in different "zone" (such as dev, QA, preprod, prod, ...) In fact, I''ve some shared resources in a zone : - SQL data-base - Mail server - ... And my apps are running in several nodes (for the same zone) : - one node as the front-end role - another as the back-office role - .... So I''d like to setup the configuration variables in one place (by zone) and reuse it among nodes in the same zone. (Obviously, every node as some specific configurations) *My question is :* - How can I share some variable svalues among nodes (like those in the same zone for exemple)? *What to do ?* - I tryed to put the zone specific variables in a dedicated configuration file andimport it in the relevant nodes. But this didn''t worked telling me that I redefined variable (as soon as I''ve several zones) - Should I create a template node by zone with thoses common varaibles? - Is there any other way to do? * * *Sample files are below:* Sample class : class p2es::plateforme_stockage( $env =''integration'', $yumrepo_host =''10.10.25.5'', $version =undef, $ensure =undef, $rwpwd ="admin", $ropwd ="reader", $probepwd ="probe", $bddhost ="10.10.25.23", $bddlogin ="l_ps", $bddpwd ="l_ps", $mailhost ="smtp.XXX.fr", $mailto ="dev-p2es@XXX.fr", $mailfrom ="dev-p2es@XXX.fr"){ # Repo YUM class{ p2es::repo: env => $env, yumrepo_host => $yumrepo_host } .... Sample node : node /^.*ps.*preprod.*$/ inherits base { # Partie de la conf mutualisée import ''../configuration/p2es_ps_conf_preprod'' # indiquer l''environnement cible $env = ''preprod'' # Le soft class{ p2es::plateforme_stockage: env => $env, yumrepo_host => $YUM_REPO_HOST, version => $PS_VERSION, ropwd => $JMX_RO_PWD, rwpwd => $JMX_RW_PWD, probepwd => $PSI_PROBE_PWD, bddhost => $BDD_HOST, bddlogin => $BDD_LOGIN, bddpwd => $BDD_PWD, mailhost => $MAIL_HOST, mailto => $MAIL_TO, mailfrom => $MAIL_FROM } } Sample configuration : $YUM_REPO_HOST="10.10.25.5" $DATASRC_HOST="10.10.25.23" $DATASRC_LOGIN="l_pe" $DATASRC_PASSWORD="l_pe" $MONGODB_HOST="10.10.25.23" $MONGODB_LOGIN="" $MONGODB_PASSWORD="" $PS_HOST="10.10.25.39" $PS_LOGIN="admin" $PS_PASSWORD="adminspassword" $CAS_VALIDATE_URL="" $CAS_LOGIN_URL="adminspassword" $CAS_LOGOUT_URL="adminspassword" $SECURITY_WS_URL="" ... Thank you for your help -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Jan-30 14:52 UTC
[Puppet Users] Re: Best practice to share variable values among nodes
On Wednesday, January 30, 2013 4:52:46 AM UTC-6, Sylvain Mougenot wrote:> > Hello, I''m new to puppet using a puppet-master. And I couldn''t figure out > what''s the best practice I need. > > *My context : * > - puppet-master with a puppet dashboard is setup and running > - few modules are ready and fully fonctionnal (tested using vagrant and > "puppet apply") > - there are some nodes in different "zone" (such as dev, QA, preprod, > prod, ...) > > In fact, > I''ve some shared resources in a zone : > - SQL data-base > - Mail server > - ... > And my apps are running in several nodes (for the same zone) : > - one node as the front-end role > - another as the back-office role > - .... > So I''d like to setup the configuration variables in one place (by zone) > and reuse it among nodes in the same zone. > (Obviously, every node as some specific configurations) > > *My question is :* > - How can I share some variable svalues among nodes (like those in the > same zone for exemple)? > > *What to do ?* > - I tryed to put the zone specific variables in a dedicated configuration > file andimport it in the relevant nodes. But this didn''t worked telling me > that I redefined variable (as soon as I''ve several zones) > - Should I create a template node by zone with thoses common varaibles? > - Is there any other way to do? > >There are very few appropriate uses for the ''import'' function, and the situation you describe is not one of them. There are several ways you could approach the situation, but my first recommendation would be to store your data in external YAML files and load it via hiera. Supposing that you have a variable $zone (or similar) by which a node''s zone can be identified, you can configure hiera to provide values appropriate for the current node''s zone. Moreover, where you have data that are common to most or all zones, you can configure it centrally instead of duplicating it for each zone. Alternatively, you can write the per-zone logic into your Puppet manifests, like so: case $zone { ''dev'': { $parm1 = ''red'' }, prod: { $parm1 = ''blue'' } } In particular, note that neither the case statement nor the individual per-case blocks narrow the scope of the declarations within. In the above example, therefore, the value set in the case statement for variable $parm1 is visible outside. Only class bodies, definition bodies, and node blocks narrow the scope of declarations within. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Wolf Noble
2013-Jan-30 15:25 UTC
Re: [Puppet Users] Best practice to share variable values among nodes
On Jan 30, 2013, at 4:52 AM, Sylvain Mougenot <sylvain.mougenot@gmail.com> wrote:> Hello, I''m new to puppet using a puppet-master. And I couldn''t figure out what''s the best practice I need. > > My context : > - puppet-master with a puppet dashboard is setup and running > - few modules are ready and fully fonctionnal (tested using vagrant and "puppet apply") > - there are some nodes in different "zone" (such as dev, QA, preprod, prod, ...) > > In fact, > I''ve some shared resources in a zone : > - SQL data-base > - Mail server > - ... > And my apps are running in several nodes (for the same zone) : > - one node as the front-end role > - another as the back-office role > - .... > So I''d like to setup the configuration variables in one place (by zone) and reuse it among nodes in the same zone. > (Obviously, every node as some specific configurations) > > My question is : > - How can I share some variable svalues among nodes (like those in the same zone for exemple)? > > What to do ? > - I tryed to put the zone specific variables in a dedicated configuration file andimport it in the relevant nodes. But this didn''t worked telling me that I redefined variable (as soon as I''ve several zones) > - Should I create a template node by zone with thoses common varaibles? > - Is there any other way to do? > > > Sample files are below: > > Sample class : > class p2es::plateforme_stockage( > $env =''integration'', > $yumrepo_host =''10.10.25.5'', > $version =undef, > $ensure =undef, > $rwpwd ="admin", > $ropwd ="reader", > $probepwd ="probe", > $bddhost ="10.10.25.23", > $bddlogin ="l_ps", > $bddpwd ="l_ps", > $mailhost ="smtp.XXX.fr", > $mailto ="dev-p2es@XXX.fr", > $mailfrom ="dev-p2es@XXX.fr"){ > > # Repo YUM > class{ p2es::repo: > env => $env, > yumrepo_host => $yumrepo_host > } > .... > > Sample node : > node /^.*ps.*preprod.*$/ inherits base { > > # Partie de la conf mutualisée > import ''../configuration/p2es_ps_conf_preprod'' > > # indiquer l''environnement cible > $env = ''preprod'' > > # Le soft > class{ p2es::plateforme_stockage: > env => $env, > yumrepo_host => $YUM_REPO_HOST, > version => $PS_VERSION, > ropwd => $JMX_RO_PWD, > rwpwd => $JMX_RW_PWD, > probepwd => $PSI_PROBE_PWD, > bddhost => $BDD_HOST, > bddlogin => $BDD_LOGIN, > bddpwd => $BDD_PWD, > mailhost => $MAIL_HOST, > mailto => $MAIL_TO, > mailfrom => $MAIL_FROM > } > } > > Sample configuration : > $YUM_REPO_HOST="10.10.25.5" > $DATASRC_HOST="10.10.25.23" > $DATASRC_LOGIN="l_pe" > $DATASRC_PASSWORD="l_pe" > $MONGODB_HOST="10.10.25.23" > $MONGODB_LOGIN="" > $MONGODB_PASSWORD="" > $PS_HOST="10.10.25.39" > $PS_LOGIN="admin" > $PS_PASSWORD="adminspassword" > $CAS_VALIDATE_URL="" > $CAS_LOGIN_URL="adminspassword" > $CAS_LOGOUT_URL="adminspassword" > $SECURITY_WS_URL="" > ... > > Thank you for your help >Hi Sylvain, Check out hiera. It contains loads of awesome, and should allow you to feed the nodes relevant variables for each zone. http://projects.puppetlabs.com/projects/hiera https://github.com/puppetlabs/hiera HTH W ________________________________ This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.