Thanks for the hint! Let me ask you a couple of questions: - Does the "puppetbackend::data" have to be imported by the node? - Is the name static, or can I name it "myclass::mydata", and use ":datasource: mydata"? - When you call hiera() inside the module, does it go to other modules to search for the "data" subclass? Or is it local (meaning, each module needs to have its own "data" subclass, and hiera will only search there)? - Can I specify a different :datasource:, so that I import a custom-made tree of data, that is independent from the modules?
The last question is about my need to define "node groups" and each group have a hiera tree with different values, that the modules don't need to be aware of, but whe they invoke hiera() they get the right data. For example: common.yaml ssh_keys: -keyA groupA.yaml ssh_keys: -keyB groupB.yaml ssk_keys: -keyC and have the ssh::site_admins class do: $keys = hiera_array("ssh_keys"). Then, depending on which groups does the node belong to (don't know yet how to define the groups a machine belongs to), it should add the group's key to the array. Also, is there any kind of documentation on how to use the hiera_puppet datasource? Thanks! Pablo On Saturday 17 March 2012 09:21:12 Gary Larizza wrote: > Hi Pablo, > > The Puppet backend accepts a 'datasource' parameter whose value will be the > class name for where it will look for Puppet variables. Take my hiera.yaml > for example: > > --- > > :backends: - puppet > : > :puppet: > :datasource: data > > I'm telling it to look for a <modulename>::data class, and to check within > that class for Puppet variables. Given that setup, I can do the following: > > # <modulepath>/puppetbackend/manifests/init.pp > class puppetbackend { > $stuff = hiera('variable') > > notify { "Stuff is: ${stuff}": } > } > > # <modulepath>/puppetbackend/manifests/data.pp > class puppetbackend::data { > $variable = 'foo' > } > > Then if I run: " puppet apply -v -e 'include puppetbackend' " I will get: > > notice: Stuff is: foo > notice: /Stage[main]/Puppetbackend/Notify[Stuff is: foo]/message: defined > 'message' as 'Stuff is: foo' > notice: Finished catalog run in 0.06 seconds > > Does that help you out? > > On Sat, Mar 17, 2012 at 2:29 AM, Pablo Fernandez <pablo.fernan...@cscs.ch>wrote: > > ** > > > > Hi all, > > > > > > > > I am trying to understand how does hiera puppet backend work, so I > > created the following example: > > > > > > > > hiera.yaml has only: > > > > --- > > > > :backends: > > - puppet > > > > > > > > --- > > > > > > > > And the node: > > > > node 'testnode' { > > > > $variable = 'kk' > > > > $thing = hiera ("variable") > > > > notify { "note: $thing": } > > > > } > > > > > > > > I don't want to use the yaml backend for now, just want to grab > > variables > > from within puppet. But then I run the agent, and it "Could not find > > data > > item variable in any Hiera data file". > > > > > > > > This probably means I am completely lost. I did not put any hierarchy, > > because I don't want to use the yaml backend, and I don't know why else > > would I need it. > > > > > > > > Could anyone shed some light on me, please? > > > > > > > > Thanks, > > Pablo > > > > -- > > 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+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/puppet-users?hl=en. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.