Ask Your Question

Hiera returning wrong environment from YAML source

asked 2016-01-04 16:33:47 -0600

masterdam79 gravatar image

Hey Comm,

Would be grateful if anyone could help me with this.

Aim: I'm trying to assign an environment other than default production using an ENC script I've written in bash.

The script calls hiera as follows where it fails:

hiera environment -y /etc/puppetlabs/code/nodes/ --config /etc/puppetlabs/code/hiera-enc.yaml -d
DEBUG: 2016-01-04 23:28:02 +0100: Hiera YAML backend starting
DEBUG: 2016-01-04 23:28:02 +0100: Looking up environment in YAML backend
DEBUG: 2016-01-04 23:28:02 +0100: Looking for data source default
DEBUG: 2016-01-04 23:28:02 +0100: Found environment in default

Content of /etc/puppetlabs/code/nodes/

environment: 'hs1-ext'

Content of /etc/puppetlabs/code/hiera-enc.yaml:

 - yaml
 - "%{::fqdn}"
 - "default"
 :datadir: /etc/puppetlabs/code/nodes

Am I overseeing anything?

Thanks in advance!


edit retag flag offensive close merge delete


I've already tried to swap the :hierarchy: values around but it only seems to look for "data source default" so my guess is that the %{::fqdn} value somehow is not being read properly. Tried different notations for "fqdn" as well, no difference.

masterdam79 gravatar imagemasterdam79 ( 2016-01-04 16:37:35 -0600 )edit

are you sure the value of $fqdn matches the hiera file name?

lavaman gravatar imagelavaman ( 2016-01-04 18:21:00 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-01-04 20:42:16 -0600

Yeah the issue is you're not passing the $::fqdn fact to the hiera command line.

Try this:

hiera environment -y /etc/puppetlabs/code/nodes/ --config /etc/puppetlabs/code/hiera-enc.yaml -d

See documentation here.

edit flag offensive delete link more


That was totally it, thanks for guiding me through this forest of documentation :-)

masterdam79 gravatar imagemasterdam79 ( 2016-01-05 02:18:58 -0600 )edit

Welcome to Debugging Hiera. ;-)

Alex Harvey gravatar imageAlex Harvey ( 2016-01-05 05:14:44 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-01-04 16:33:47 -0600

Seen: 140 times

Last updated: Jan 04 '16