Guillem Liarte
2012-Nov-01 13:35 UTC
[Puppet Users] Dynamic list of files managed from hiera
All, I use hiera in an straight way, for example: --- mode: ''0644'' that makes easy to do: file { somefile: mode => hiera(''mode'') } So far so good. But what about more complex structures? I would liek to be able to handle hashes of data like this: in yaml: --- file_list: - file1: fname: ''config.conf'' fpath: ''/path/to/destination/'' fmode: ''640'' fowner: ''sam'' fgroup: ''admin'' - file2: fname: ''parameters.xml'' fpath: ''/path/to/destination/'' fmode: ''660'' fowner: ''tom'' fgroup: ''finance'' Is it possible to handle this right now? What can I do in order to get a list of items that contain attributes? I understand taht this type of parsing happens for example when an ENC produces YAML in this way: clasees: myapp: parameter1: ''value1'' parameter2: ''value2'' Can I do something similar to this with puppet-hiera? And also, is the a decent piece of *documentation* for hiera and hiera-puppet? there seems to be almost nothing but fragmented documentation. I am happy top read and research all this in my own but I have struggled finding documentation. Many thanks in advance! Guillem -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/PkapS7HcGPsJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
jcbollinger
2012-Nov-02 14:39 UTC
[Puppet Users] Re: Dynamic list of files managed from hiera
On Thursday, November 1, 2012 8:35:46 AM UTC-5, Guillem Liarte wrote:> > > All, > > I use hiera in an straight way, for example: > > --- > mode: ''0644'' > > that makes easy to do: > > file { somefile: > mode => hiera(''mode'') > } > > > So far so good. But what about more complex structures? I would liek to be > able to handle hashes of data like this: > > in yaml: > > --- > file_list: > - file1: > fname: ''config.conf'' > fpath: ''/path/to/destination/'' > fmode: ''640'' > fowner: ''sam'' > fgroup: ''admin'' > - file2: > fname: ''parameters.xml'' > fpath: ''/path/to/destination/'' > fmode: ''660'' > fowner: ''tom'' > fgroup: ''finance'' > > > Is it possible to handle this right now?Yes. Hiera understands general YAML values (at least YAML 1.1; I don''t know about 1.2) associated with top-level scalar keys. Complex values are presented in Puppet via the natural mapping to Puppet hashes and arrays, nested as needed.> What can I do in order to get a list of items that contain attributes? I > understand taht this type of parsing happens for example when an ENC > produces YAML in this way: > > clasees: > myapp: > parameter1: ''value1'' > parameter2: ''value2'' > > Can I do something similar to this with puppet-hiera? >Again, yes. The only caveat here is that the top level of your data document should associate values with scalar keys. Hiera looks up values by those top-level keys.> > And also, is the a decent piece of *documentation* for hiera and > hiera-puppet? there seems to be almost nothing but fragmented > documentation. I am happy top read and research all this in my own but I > have struggled finding documentation. > >I am unaware of any comprehensive documentation for Hiera. Perhaps that overstates the case a bit, though, as "comprehensive" suggests big and complicated, and that''s not a good characterization of Hiera. If you have not already seen these documents, then you should read them: https://github.com/puppetlabs/hiera (scroll down) https://github.com/puppetlabs/hiera-puppet (scroll down) http://puppetlabs.com/blog/first-look-installing-and-using-hiera/ Those should be enough to get anyone up and going with Hiera, but they do, I think, miss details about some of Hiera''s more advanced capabilities. Until better documentation becomes available, this forum is a good place to pose questions. And there''s always the code, of course, which is fairly small. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/rgjMLVRG_a0J. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Ellison Marks
2012-Nov-02 18:44 UTC
[Puppet Users] Re: Dynamic list of files managed from hiera
You also might look at R.I.P''s blog posts on the subject. They don''t have info on the 3.0 behavior, of course, but they were enormously useful to me when I was first trying to understand the system. http://www.devco.net/archives/2011/06/05/hiera_a_pluggable_hierarchical_data_store.php http://www.devco.net/archives/2011/06/06/puppet_backend_for_hiera.php http://www.devco.net/archives/2011/06/11/puppet_backend_for_hiera_part_2.php On Friday, November 2, 2012 7:39:19 AM UTC-7, jcbollinger wrote:> > > > On Thursday, November 1, 2012 8:35:46 AM UTC-5, Guillem Liarte wrote: >> >> >> All, >> >> I use hiera in an straight way, for example: >> >> --- >> mode: ''0644'' >> >> that makes easy to do: >> >> file { somefile: >> mode => hiera(''mode'') >> } >> >> >> So far so good. But what about more complex structures? I would liek to >> be able to handle hashes of data like this: >> >> in yaml: >> >> --- >> file_list: >> - file1: >> fname: ''config.conf'' >> fpath: ''/path/to/destination/'' >> fmode: ''640'' >> fowner: ''sam'' >> fgroup: ''admin'' >> - file2: >> fname: ''parameters.xml'' >> fpath: ''/path/to/destination/'' >> fmode: ''660'' >> fowner: ''tom'' >> fgroup: ''finance'' >> >> >> Is it possible to handle this right now? > > > > Yes. Hiera understands general YAML values (at least YAML 1.1; I don''t > know about 1.2) associated with top-level scalar keys. Complex values are > presented in Puppet via the natural mapping to Puppet hashes and arrays, > nested as needed. > > > >> What can I do in order to get a list of items that contain attributes? I >> understand taht this type of parsing happens for example when an ENC >> produces YAML in this way: >> >> clasees: >> myapp: >> parameter1: ''value1'' >> parameter2: ''value2'' >> >> Can I do something similar to this with puppet-hiera? >> > > > Again, yes. The only caveat here is that the top level of your data > document should associate values with scalar keys. Hiera looks up values > by those top-level keys. > > > >> >> And also, is the a decent piece of *documentation* for hiera and >> hiera-puppet? there seems to be almost nothing but fragmented >> documentation. I am happy top read and research all this in my own but I >> have struggled finding documentation. >> >> > > I am unaware of any comprehensive documentation for Hiera. Perhaps that > overstates the case a bit, though, as "comprehensive" suggests big and > complicated, and that''s not a good characterization of Hiera. > > If you have not already seen these documents, then you should read them: > > https://github.com/puppetlabs/hiera (scroll down) > https://github.com/puppetlabs/hiera-puppet (scroll down) > http://puppetlabs.com/blog/first-look-installing-and-using-hiera/ > > Those should be enough to get anyone up and going with Hiera, but they do, > I think, miss details about some of Hiera''s more advanced capabilities. > Until better documentation becomes available, this forum is a good place to > pose questions. And there''s always the code, of course, which is fairly > small. > > > John > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/xAzQ0xMzMXoJ. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.