I have this, I think common, situation: - NodeDB VM with MySQL - NodeApp VM with an application that uses the MySQL DB Obivuously both needs to have information on the DB (like user, DB name, etc.) Since DB will be created in the NodeDB by the MySQL module from puppetlabs and the app will just connect to the DB and do its work, but need to set the configuration parameters. Now ... since App can be installed at any moments at a precise point in time will have to modify the NodeDB definition adding the DB for app and than create/modify the NodeApp to configure app. Can I write down the DB info just once in hiera and refer to these common data from the two nodes? Also passing this data to standard modules in a proper way? This could become handy when I''ll have to add a third node, let''s say NodeBI that needs to access the app DB for business intelligence reasons, so I''ll have to configure a new node with the same DB data. I think that there is the need to access a much higher scope information, but haven''t found any clear (at least for me) documentation on this. Thanks Luca -- 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-Apr-29 14:33 UTC
[Puppet Users] Re: Sharing data between nodes with hiera
On Monday, April 29, 2013 2:12:54 AM UTC-5, Luca Gioppo wrote:> > I have this, I think common, situation: > > - NodeDB VM with MySQL > - NodeApp VM with an application that uses the MySQL DB > > Obivuously both needs to have information on the DB (like user, DB name, > etc.) > Since DB will be created in the NodeDB by the MySQL module from puppetlabs > and the app will just connect to the DB and do its work, but need to set > the configuration parameters. > > Now ... > since App can be installed at any moments at a precise point in time will > have to modify the NodeDB definition adding the DB for app and than > create/modify the NodeApp to configure app. > > Can I write down the DB info just once in hiera and refer to these common > data from the two nodes?Yes, absolutely. This sort of thing is one of hiera''s core use cases. Did you have specific concerns about it?> Also passing this data to standard modules in a proper way? > >I don''t understand what you''re asking. In particular, I don''t know what "standard modules" means to you. Generally speaking, however, there are three key ways by which classes (in modules) can obtain data to work with: 1. The data can be hard-coded into the class 2. The data can be drawn from class variables (including a class''s own parameters) 3. The data can be retrieved or computed via a function If the main source of the data is hiera, then ultimately option 3 is how the data get into Puppet (using the hiera() function explicitly or else relying on automated class parameter binding). The main decision you have here is whether option 3 will be used everywhere the data in question are needed, or whether it will be used once to set class variables (maybe parameters) of one or more classes, and then other classes will obtain it via those class variables.> This could become handy when I''ll have to add a third node, let''s say > NodeBI that needs to access the app DB for business intelligence reasons, > so I''ll have to configure a new node with the same DB data. > > I think that there is the need to access a much higher scope information, > but haven''t found any clear (at least for me) documentation on this. >You should consider creating a class purposed with stewardship of the data. It would load them from hiera either via explicit hiera() calls (my preference) or via automated binding to class parameters (Puppet 3+ only). Other classes that need the data would then reference the steward class''s class variables to get them. Place the steward class in an appropriate module and give it an appropriate name for the scope of the data it handles. 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.
Luca Gioppo
2013-Apr-29 22:20 UTC
[Puppet Users] Re: Sharing data between nodes with hiera
I''m new of hiera and I was thinking that it was possible to declare hiera variables just linked to nodes or classes. Indeed the option of getting the data using the hiera() function allows for a common.yaml file to host the global information and thus will follow your suggestion on having classes that build the needed configuration. Thanks -- 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.