Change the hiera 5 environment layer hiera.yaml location

asked 2017-08-03 05:04:18 -0600

geedoubleya gravatar image

I am using puppet5 & hiera5 on a puppet master from separate git repos.
The code is deployed using r10k into their respective locations using the branch to environment directory mapping. Due to the environment conflict limitation in r10k (apologies if this is no longer the case) I use a separate location for my hieradata:

Puppet code - /etc/puppetlabs/code/envirnments/
Hiera code - /etc/puppetlabs/code/hieradata/

I have a global hiera.yaml file in /etc/puppetlabs/puppet/hiera.yaml and an environment specific hiera.yaml file in my hiera branch / environment location.

e.g. /etc/puppetlabs/code/hieradata/production/hiera.yaml

My environment hiera.yaml is ignored due to its location, it is expected to be where my puppet <ENVIRONMENT> code is:


taken from

but instead it is:


The only solution that I have been able to find is to locate a hiera.yaml in my puppet code repo with a datadir set to

datadir: ../../hieradata/%{::environment}/hieradata (it must be relative)

Which works ok but is not ideal so I am looking for other solutions.

Even if I set the global hiera.yaml datadir to:

/etc/puppetlabs/code/hieradata/%{::environment}/ (it can be a full path)

and do not have a hiera.yaml file in my puppet repo, hiera works, but the environmental hiera.yaml located there is ignored.

Another idea was to swap the locations but then my puppet code does not work.

So ideally what I need to do is set the environment layer hier.yaml location as it seems to be hard coded to <ENVIRONMENT>, which is where my puppet code is.

I still want to use r10k and I want to host my environmental hiera.yaml in my hiera repo, and I definitely need a separate Hiera repo!

edit retag flag offensive close merge delete


Looking at treating the hiera repo as a puppet module and importing it using the Puppetfile. Could be a suitable solution.

geedoubleya gravatar imagegeedoubleya ( 2017-08-07 03:38:30 -0600 )edit