Ask Your Question
0

Hiera returning wrong environment from YAML source

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

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/test.hs1.nl.yaml --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
production

Content of /etc/puppetlabs/code/nodes/test.hs1.nl.yaml:

---
environment: 'hs1-ext'

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

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

Am I overseeing anything?

Thanks in advance!

Richard

edit retag flag offensive close merge delete

Comments

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 -0500 )edit

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

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

1 Answer

Sort by ยป oldest newest most voted
1

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

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

Try this:

hiera environment ::fqdn=test.hs1.nl -y /etc/puppetlabs/code/nodes/test.hs1.nl.yaml --config /etc/puppetlabs/code/hiera-enc.yaml -d

See documentation here.

edit flag offensive delete link more

Comments

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

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

Welcome to Debugging Hiera. ;-)

Alex Harvey gravatar imageAlex Harvey ( 2016-01-05 05:14:44 -0500 )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

Stats

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

Seen: 96 times

Last updated: Jan 04 '16