$ cat /etc/hiera.yaml --- :hierarchy: - %{operatingsystem} - common :backends: - yaml :yaml: :datadir: /tmp/hieradata $ cat /tmp/hieradata/Debian.yaml --- kitty : ''Handsome'' $ cat /tmp/hieradata/common.yaml --- kitty : ''Evil'' $ facter operatingsystem Debian $ hiera -d kitty DEBUG: Thu Feb 09 10:09:01 -0500 2012: Hiera YAML backend starting DEBUG: Thu Feb 09 10:09:01 -0500 2012: Looking up cat in YAML backend DEBUG: Thu Feb 09 10:09:01 -0500 2012: Looking for data source common Evil $ hiera -d kitty operatingsystem=Debian DEBUG: Thu Feb 09 10:46:20 -0500 2012: Hiera YAML backend starting DEBUG: Thu Feb 09 10:46:20 -0500 2012: Looking up cat in YAML backend DEBUG: Thu Feb 09 10:46:20 -0500 2012: Looking for data source Debian Handsome Shouldn''t Debian.yaml take priority over common.yaml though? Not sure why I need to pass operatingsystem=Debian in as an argument to hiera Best, Adam -- 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.
Hiera as a command line tool is unaware of the $::operatingsystem variable available to Puppet as a fact. So when running through puppet, operatingsystem would be a known value, but when running through the command line, you need to specify whatever information hiera needs to parse. -Eric -- Eric Shamow Professional Services http://puppetlabs.com/ (c)631.871.6441 On Thursday, February 9, 2012 at 10:49 AM, windowsrefund wrote:> $ cat /etc/hiera.yaml > --- > :hierarchy: > - %{operatingsystem} > - common > :backends: > - yaml > :yaml: > :datadir: /tmp/hieradata > > $ cat /tmp/hieradata/Debian.yaml > --- > kitty : ''Handsome'' > > $ cat /tmp/hieradata/common.yaml > --- > kitty : ''Evil'' > > $ facter operatingsystem > Debian > > $ hiera -d kitty > DEBUG: Thu Feb 09 10:09:01 -0500 2012: Hiera YAML backend starting > DEBUG: Thu Feb 09 10:09:01 -0500 2012: Looking up cat in YAML backend > DEBUG: Thu Feb 09 10:09:01 -0500 2012: Looking for data source common > Evil > > $ hiera -d kitty operatingsystem=Debian > DEBUG: Thu Feb 09 10:46:20 -0500 2012: Hiera YAML backend starting > DEBUG: Thu Feb 09 10:46:20 -0500 2012: Looking up cat in YAML backend > DEBUG: Thu Feb 09 10:46:20 -0500 2012: Looking for data source Debian > Handsome > > Shouldn''t Debian.yaml take priority over common.yaml though? Not sure > why I need to pass operatingsystem=Debian in as an argument to hiera > > Best, > Adam > > -- > 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 (mailto:puppet-users@googlegroups.com). > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users+unsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
To add: there''s a reason for this - you are likely running the command line tool on the master, where facter output does not match what it would be when evaluating a client. So you are essentially saying "for a client that looks like X, what would hiera tell me?" One thought would be to write a quick script to grab the cached facts for a node and turn the relevant ones into hiera parameters, then use this to run hiera against an individual host. -Eric -- Eric Shamow Professional Services http://puppetlabs.com/ (c)631.871.6441 On Thursday, February 9, 2012 at 10:52 AM, Eric Shamow wrote:> Hiera as a command line tool is unaware of the $::operatingsystem variable available to Puppet as a fact. So when running through puppet, operatingsystem would be a known value, but when running through the command line, you need to specify whatever information hiera needs to parse. > > -Eric > > -- > > Eric Shamow > Professional Services > http://puppetlabs.com/ > (c)631.871.6441 > > > On Thursday, February 9, 2012 at 10:49 AM, windowsrefund wrote: > > > $ cat /etc/hiera.yaml > > --- > > :hierarchy: > > - %{operatingsystem} > > - common > > :backends: > > - yaml > > :yaml: > > :datadir: /tmp/hieradata > > > > $ cat /tmp/hieradata/Debian.yaml > > --- > > kitty : ''Handsome'' > > > > $ cat /tmp/hieradata/common.yaml > > --- > > kitty : ''Evil'' > > > > $ facter operatingsystem > > Debian > > > > $ hiera -d kitty > > DEBUG: Thu Feb 09 10:09:01 -0500 2012: Hiera YAML backend starting > > DEBUG: Thu Feb 09 10:09:01 -0500 2012: Looking up cat in YAML backend > > DEBUG: Thu Feb 09 10:09:01 -0500 2012: Looking for data source common > > Evil > > > > $ hiera -d kitty operatingsystem=Debian > > DEBUG: Thu Feb 09 10:46:20 -0500 2012: Hiera YAML backend starting > > DEBUG: Thu Feb 09 10:46:20 -0500 2012: Looking up cat in YAML backend > > DEBUG: Thu Feb 09 10:46:20 -0500 2012: Looking for data source Debian > > Handsome > > > > Shouldn''t Debian.yaml take priority over common.yaml though? Not sure > > why I need to pass operatingsystem=Debian in as an argument to hiera > > > > Best, > > Adam > > > > -- > > 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 (mailto:puppet-users@googlegroups.com). > > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com (mailto:puppet-users+unsubscribe@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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Excellent. I didn''t realize this behavior of the standalone hiera binary. Thanks again. -- 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.