Interpolate a Puppet variable
The most common thing to interpolate is the value of a Puppet top scope variable.
The facts
hash,
trusted
hash, and server_facts
hash are the most useful variables to
Hiera and behave predictably.
trusted.certname
. To reference a node’s
environment, use server_facts.environment
.Avoid using local variables, namespaced variables from classes (unless the class has already been evaluated), and Hiera-specific pseudo-variables (pseudo-variables are not supported in Hiera 5).
If you are using Hiera 3 pseudo-variables, see Puppet variables passed to Hiera.
Puppet makes facts available in two
ways: grouped together in the facts
hash ( $facts['networking']
), and
individually as top-scope variables ( $networking
).
When you use individual fact variables, specify the (empty) top-scope namespace for them, like this:
%{::networking}
Not like this:
%{networking}
$facts
is, and local scopes can set unrelated variables with the same
names. In most of Puppet, you don’t have to worry
about unknown scopes overriding your variables, but in Hiera you do.Use the name of the variable, omitting the leading
dollar sign ($
). Use
the Hiera key.subkey notation to access a member of a
data structure. For example, to interpolate the value of $facts['networking']['domain']
write:
smtpserver:
"mail.%{facts.networking.domain}"