Hello, I have a yaml file with a hash of network interfaces (ifaces hash), each nic has an associated ipaddress and netmask. Using hiera ifaces fqdn=host.mycompany.com I can get all interfaces back. Is there a way using the hiera cli to get a specific value of a key within the hash? e.g. hiera ifaces fqdn=host.mycompany.com {"eth0"=>{"ipaddress"=>"10.4.115.48", "netmask"=>"255.255.255.0"}, "eth0:1"=>{"ipaddress"=>"10.4.115.58", "netmask"=>"255.255.255.0"}} Can I with a single hiera command get info of only the interface eth0? Or get just the ipaddress of interface eth0? Or was hiera not meant for this kind of use? Best Regards, Jo -- 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.
If you have created a hash in your hiera data, I believe that hiera can only return that hash. If you want a piece of it, you can process the hash after you get it out of hiera and into your manifest. I do not have a handy example to offer here, but maybe another list member can help with that. “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Original Message ----- From: "jdt" <jo.de.troy@gmail.com> To: puppet-users@googlegroups.com Sent: Thursday, May 16, 2013 7:49:49 AM Subject: [Puppet Users] hiera query question Hello, I have a yaml file with a hash of network interfaces (ifaces hash), each nic has an associated ipaddress and netmask. Using hiera ifaces fqdn=host.mycompany.com I can get all interfaces back. Is there a way using the hiera cli to get a specific value of a key within the hash? e.g. hiera ifaces fqdn=host.mycompany.com {"eth0"=>{"ipaddress"=>"10.4.115.48", "netmask"=>"255.255.255.0"}, "eth0:1"=>{"ipaddress"=>"10.4.115.58", "netmask"=>"255.255.255.0"}} Can I with a single hiera command get info of only the interface eth0? Or get just the ipaddress of interface eth0? Or was hiera not meant for this kind of use? Best Regards, Jo -- 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 . -- 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.
On Thursday, May 16, 2013 6:49:49 AM UTC-5, jdt wrote:> > Hello, > > I have a yaml file with a hash of network interfaces (ifaces hash), each > nic has an associated ipaddress and netmask. > Using hiera ifaces fqdn=host.mycompany.com I can get all interfaces back. > Is there a way using the hiera cli to get a specific value of a key within > the hash? > > e.g. hiera ifaces fqdn=host.mycompany.com > {"eth0"=>{"ipaddress"=>"10.4.115.48", "netmask"=>"255.255.255.0"}, > "eth0:1"=>{"ipaddress"=>"10.4.115.58", "netmask"=>"255.255.255.0"}} > > > Can I with a single hiera command get info of only the interface eth0? > Or get just the ipaddress of interface eth0? > Or was hiera not meant for this kind of use? > >You seem to be asking for some kind of XPATH-like feature, but hiera does not provide one. Via its programmatic interface (i.e. in Puppet), you would simply take the hash object returned by hiera and access the desired element by its key. If you want to be able to do similar from the command line then you probably should write your own Ruby program that does the same. 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.