Ask Your Question

Hiera 5 environment specific lookup of yaml (puppet lookup)

asked 2017-10-30 16:17:48 -0600

nimika gravatar image

updated 2017-11-01 01:29:29 -0600

Mr_Sharma gravatar image

Hello, Can someone explain how new Hiera 5 works ? what is data in ? datadir : data is it a directory and is it looking for this directory in default path /etc/puppetlabs/puppet/data ? for hiera global yaml ? is it expecting the data dir to be present and the hierarchy files defined ? When i tried to convert Hiera 3 to Hiera 5 yaml this line always gives an error datadir : data (Psych syntax error)

I also created env specific hiera.yaml file /etc/puppetlabs/code/environment/production/hiera.yaml I tried giving a different location in global hiera.yaml which did not complain about the datadir. as below

version: 5
  - name: "Per-node data (yaml version)"
    path: "nodes/%{::fqdn}.yaml"
  - name: common
    path: common.yaml
  data_hash: yaml_data
  datadir: "/etc/puppetlabs/code/environments/global/hieradata5"

Now question is how do i get environment specific value using puppet lookup ? i am trying to run the below commands from puppet master

puppet lookup <variable> --environment production ----->does not work

puppet lookup <variable> environment=production ---> does not work

edit retag flag offensive close merge delete


I think the correct logic is: one hiera.yaml for environment and one datadir too, like that you have the hieradata sperated for every environment

c4f4t0r gravatar imagec4f4t0r ( 2017-11-02 03:24:05 -0600 )edit

try using `--explain` to see what hiera thinks about your configuration - it is easy to make typos on names, paths etc. and the explain output will reveal which paths are read and how the configurations and data was interpreted by hiera.

Henrik Lindberg gravatar imageHenrik Lindberg ( 2017-11-02 04:17:17 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-11-02 04:15:28 -0600

Henrik Lindberg gravatar image

In hiera 5 the default datadir for everything in a hiera.yaml is the directory named data in the same directory as that hiera.yaml.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2017-10-30 16:17:48 -0600

Seen: 383 times

Last updated: Nov 02 '17