1
votes

I am pretty new to puppet. I configured a hiera file, whose path is /etc/puppetlabs/puppet/hiera.yaml, as so

version: 5

hierarchy: []

backends:
  - yaml

yaml:
  - datadir: /etc/puppetlabs/puppet/some_dir

and I get this error

 Warning: The function 'hiera' is deprecated in favor of using 'lookup'. See https://docs.puppet.com/puppet/5.3/reference/deprecated_language.html
       (file & line not available)
    Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'user_dir' failed:  The Lookup Configuration at '/etc/puppetlabs/puppet/hiera.yaml' has wrong type, unrecognized key 'backends'
      The Lookup Configuration at '/etc/puppetlabs/puppet/hiera.yaml' has wrong type, unrecognized key 'yaml' at /etc/puppetlabs/code/environments/production/manifests/site.pp:30:17 on node puppet,some_cluster_DNS.internal

Initially, I had those kinds of format for the keys :backends: :yaml: but it seemed it is not regular one for the 5 version, so that I deleted the : sign

Someone has an idea ?

1

1 Answers

2
votes

First, in terms of that warning, you should definitely switch over to the Puppet lookup function from the Hiera hiera functions if you are using Hiera >= 4: https://puppet.com/docs/puppet/4.10/hiera_use_function.html

Second, in terms of that error, I would consult the documentation on how to setup a Hiera 5 config file: https://puppet.com/docs/puppet/4.10/hiera_config_yaml_5.html

Using the proper format, your config file would look like:

# /etc/puppetlabs/puppet/hiera.yaml
version: 5

defaults:
  - data_hash: yaml_data
  - datadir: /etc/puppetlabs/puppet/some_dir

hierarchy: []

What you are trying to do on the last line (specify a specific datadir for the yaml_data backend) is not allowed in Hiera 5. If you want to specify a datadir for a specific backend, then you need to specify a level of the hierarchy for just that backend (or just that backend's datadir; you can customize in several depths of matrices with it) and specify a datadir there. For example:

hierarchy:
  - name: yaml data
    data_hash: yaml_data
    datadir: /etc/puppetlabs/puppet/some_dir
    paths:
      - "%{trusted.certname}.yaml"
      - common.yaml