On Monday, April 15, 2013 12:06:25 PM UTC-5, Ygor wrote:
>
> http://docs.puppetlabs.com/hiera/1/hierarchy.html#location-and-syntax 
> Dynamic data source - It says I should use %{::variable} notation for the 
> hierarchy in the hiera.yaml file. 
>


Well, that overstates the case slightly.  The docs give an example with :: 
notation, so one would expect that to work, but that's not the same thing 
as saying that you should prefer that style to any other.

 

>
> RHEL 5, Puppet 3.1.1, Hiera 1.2.0 
>
> /etc/puppet/hiera.yaml : 
> --- 
> :backends: 
>   - yaml   
> :yaml: 
>   :datadir: '/etc/puppet/hieradata' 
> :logger: console 
> :hierarchy: 
>   - %{environment}/common 
>   - common 
>
> /etc/puppet/hieradata/common.yaml : 
> --- 
> #foo:  barr 
>
> /etc/puppet/hieradata/dev/common.yaml : 
> --- 
> foo:  boo 
>
>
> If I use the "::" top level scope, it does not work. 
>
> [root puppet]# hiera foo -d -c /etc/puppet/hiera.yaml environment=dev 
> DEBUG: Mon Apr 15 12:52:51 -0400 2013: Hiera YAML backend starting 
> DEBUG: Mon Apr 15 12:52:51 -0400 2013: Looking up foo in YAML backend 
> DEBUG: Mon Apr 15 12:52:51 -0400 2013: Looking for data source common 
> nil 
>
> If I remove the double-colon, (and restart puppetmaster) it works. 
>
> [root puppet]# hiera foo -d -c /etc/puppet/hiera.yaml environment=dev 
> DEBUG: Mon Apr 15 12:53:11 -0400 2013: Hiera YAML backend starting 
> DEBUG: Mon Apr 15 12:53:11 -0400 2013: Looking up foo in YAML backend 
> DEBUG: Mon Apr 15 12:53:11 -0400 2013: Looking for data source dev/common 
> DEBUG: Mon Apr 15 12:53:11 -0400 2013: Found foo in dev/common 
> boo 
>
> The debug output from the first try even shows that it is not looking for 
> the environment. 
>
> What am I doing wrong, please ? 
>


I don't think you're doing anything wrong, per se -- either the behavior or 
the docs are buggy.  If it has not already been reported, then I would 
recommend that you file a ticket.

Meanwhile, use what works.  There isn't anything inherently wrong that, 
though in principle it may open you up to problems if ${::environment} is 
somewhere shadowed by a local ${::foo::environment} or an ${environment} 
node variable.  I would expect the former to be relevant only to explicit 
hiera() calls in the body of a class, not automated data binding.


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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to