Grant, A variable that starts with two colons (::variable) fully qualifies a top-scope variable. See page 28 in "Extending Puppet" for more information about variable scope. That discussion doesn't mention that Facter facts are considered top scope.
It's best practice to avoid using local variables when defining the Hiera hierarchy. The best practices described here https://docs.puppetlabs.com/hiera/1/puppet.html#best-practices and here https://docs.puppetlabs.com/hiera/1/variables.html#passing-variables-to-hiera both mention reasons to avoid specifying your hierarchy with local variables. Specifically, "In Hiera, a re-used fact name can have more distant effects, so you still > need to defend against it." %{::env} directly refers to the Facter fact whereas %{{env}} is free to interpolate from other scopes before ever reaching the top-scope. The examples you see that don't use double colons are probably referencing variables in node or class scope. -Alex On Wed, Apr 29, 2015 at 12:04 PM, Grant Schoep <[email protected]> wrote: > I'm using: > CentOS 7.1 > Puppet 3.6.2 > Hiera 1.3.4 > > I'm following some very simple examples and learning how to use hiera. One > thing has me confused. Is sometimes I see examples having :: and some not. > > I have three files in use here. > > *____________* > *my hiera.yaml file* > --- > :backends: > - yaml > > :hierarchy: > - "nodes/%{::fqdn}" > - "env/%{::env}" > - common > > :yaml: > :datadir: /etc/puppet/hieradata > __________ > > *My /etc/puppet/hieradata/common.yaml* > --- > ldap_servers: > - 10.1.1.2 > - 10.1.1.3 > ___________ > > *My /etc/puppet/hieradata/env/test.yaml* > --- > ldap_servers: > - 10.1.1.4 > _______________ > > > If I run "hiera ldap_servers" I get > ["10.1.1.2", "10.1.1.3"] > > If I run "hiera ldap_servers env=test" I STILL get > ["10.1.1.2", "10.1.1.3"] > > I would have expected > ["10.1.1.4"] > > > Many examples I have seen, including the one in "Extending Puppet, by > Alessandro Franceschi" Seem to says this should work (the env part). > > I mucked around with it and removed changed my - "env/%{::env}" line to > - "env/%{env}" in my hiera.yaml file. And presto it works as expected now, > just returning the 10.1.1.4 > > > So my question is, what is the "::" doing? I see many examples with and > without it. > > Thanks > > > -- > 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 view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/8314abdd-d125-4c00-946f-986e5105445d%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/8314abdd-d125-4c00-946f-986e5105445d%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Alex Elman -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAD-8G_qdsSsY1gDeaLTMTmzK243rxjuAmcedepABe%2BuRH73h9Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
