Evelio VILA
2012-Nov-23 13:22 UTC
[Puppet Users] how to query yaml file with hiera function.
Hi guys, i have a hiera.yaml config file like this: --- :hierarchy: - %{env}/%{tmp_module_name} - %{env}/%{tmp_module_name}.common :backends: - yaml :yaml: :datadir: ''/etc/puppet/hieradata'' I also have a test/some_module.yaml file like this: --- db: root : pass port : ''3306'' I am also using the hiera function from a template like this class.pp $::class::var=''db'' template.erb <%= scope.function_hiera([var]) %> and that returns as expected the ''db'' hash... however , I would like to query the yaml file directly from the hiera function with something like: scope.function_hiera([var:root]), so to have access directly to the root:pass pair. but that doesnt seem to work. I''ve tried several possibilities, eg: ([var:''root'']), ([$var::''root'']), ([$::class::var:root]), ([var:[''root'']]) without success, Now i know that something like <%= scope.function_hiera([var])[''root''] would work! The problem with this approach is that the next level in the hierarchy would never be reached since the ''db'' key will always be located in the first level... but what if I would like to use something like this: First search level: --- db: root : pass port : ''3999'' Second search level --- db: root : pass port : ''3999'' path : ''foo'' then the path:foo pair would never be located... Btw, are there any plans to fix this soon: http://projects.puppetlabs.com/issues/14985 thanks in advance, evelio Using ubuntu 12.04 LTS Package: puppet Version: 3.0.1-1puppetlabs1 -- 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/-/wWVVXkBB-ywJ. 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.
Dominik Żyła
2012-Nov-23 19:01 UTC
Re: [Puppet Users] how to query yaml file with hiera function.
Hi, 2012/11/23 Evelio VILA <eveliovila@gmail.com>> Hi guys, > > i have a hiera.yaml config file like this: > > --- > :hierarchy: > - %{env}/%{tmp_module_name} > - %{env}/%{tmp_module_name}.common > :backends: > - yaml > :yaml: > :datadir: ''/etc/puppet/hieradata'' > > > I also have a test/some_module.yaml file like this: > > --- > db: > root : pass > port : ''3306'' > > > I am also using the hiera function from a template like this > > class.pp > $::class::var=''db'' > > template.erb > <%= scope.function_hiera([var]) %>Try this: <%= scope.function_hiera([var[''root'']]) %> -- Dominik Żyła -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Evelio VILA
2012-Nov-26 08:43 UTC
Re: [Puppet Users] how to query yaml file with hiera function.
> Hi, > > 2012/11/23 Evelio VILA <eveli...@gmail.com <javascript:>> > >> Hi guys, >> >> i have a hiera.yaml config file like this: >> >> --- >> :hierarchy: >> - %{env}/%{tmp_module_name} >> - %{env}/%{tmp_module_name}.common >> :backends: >> - yaml >> :yaml: >> :datadir: ''/etc/puppet/hieradata'' >> >> >> I also have a test/some_module.yaml file like this: >> >> --- >> db: >> root : pass >> port : ''3306'' >> >> >> I am also using the hiera function from a template like this >> >> class.pp >> $::class::var=''db'' >> >> template.erb >> <%= scope.function_hiera([var]) %> > > > Try this: <%= scope.function_hiera([var[''root'']]) %> >Thanks Dominik but that wont work neither, already tried that :( on the agent: err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template module/template.erb: Filepath: /usr/lib/ruby/vendor_ruby/hiera_puppet.rb Line: 16 Detail: Could not find data item in any Hiera data file and no default supplied at /etc/puppet/modules/module/manifests/create_data.pp:8 on node X warning: Not using cache on failed catalog err: Could not retrieve catalog; skipping run on the master: hiera(): Looking up in YAML backend : hiera(): Looking for data source env/module : hiera(): Looking for data source env/module.common : hiera(): Looking for data source module.common : hiera(): Looking for data source common : Failed to parse template module/template.erb: : Filepath: /usr/lib/ruby/vendor_ruby/hiera_puppet.rb : Line: 16 : Detail: Could not find data item in any Hiera data file and no default supplied : at /etc/puppet/modules/module/manifests/create_data.pp:8 on node X : Failed to parse template module/template.erb: : Filepath: /usr/lib/ruby/vendor_ruby/hiera_puppet.rb : Line: 16 : Detail: Could not find data item in any Hiera data file and no default supplied : at /etc/puppet/modules/module/manifests/create_data.pp:8 on node X : Failed to parse template module/template.erb: : Filepath: /usr/lib/ruby/vendor_ruby/hiera_puppet.rb : Line: 16 : Detail: Could not find data item in any Hiera data file and no default supplied : at /etc/puppet/modules/module/manifests/create_data.pp:8 on node X : Handling request: PUT /production/report/X here is my func: <%= scope.function_hiera([cluster[''port'']]) %> yaml file: --- cluster: root : pass port : ''9938'' thanks in advance.. evelio -- 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/-/bzHviZ2FGQIJ. 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.
Evelio VILA
2012-Nov-26 08:48 UTC
Re: [Puppet Users] how to query yaml file with hiera function.
> > <%= scope.function_hiera([cluster[''port'']]) %> >using the var name or the string direclty wont work... <%= scope.function_hiera([var[''port'']]) %> evelio -- 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/-/5mutU_BrJAEJ. 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.