Failed to start Hiera: RuntimeError: v5 hiera.yaml is only to be used inside an environment or a module and cannot be given to the global hiera

asked 2018-04-12 15:43:48 -0500

whoisearth gravatar image

I'm getting started with managing my code using hiera. Here's what my hiera.yaml looks like:

---
version: 5

defaults:
  datadir: data
  data_hash: yaml_data

hierarchy:
  - name: "Secret data (encrypted)"
    lookup_key: eyaml_lookup_key
    path: "secret.eyaml"
    options:
      gpg_gnupghome: ''
  - name: "Host-specific data"
    path: "nodes/%{trusted.certname}.yaml"
  - name: "OS release-specific data"
    path: "os/%{facts.os.release.major}.yaml"
  - name: "OS distro-specific data"
    path: "os/%{facts.os.distro.codename}.yaml"
  - name: "Common defaults"
    path: "common.yaml"

and here is my common.yaml

resolv_conf::nameserver:
  - 10.77.1.20

profile::ntp::servers:
  - 0.us.pool.ntp.org iburst
  - 1.us.pool.ntp.org iburst
  - 2.us.pool.ntp.org iburst
  - 3.us.pool.ntp.org iburst

I'm not seeing the values push out to my nodes when doing puppet-code deploy --all --waitconf

If I try to run hiera -d -c hiera.yaml resolv_conf::nameservers I get the following error:

/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera/config.rb:32:in `load': v5 hiera.yaml is only to be used inside an environment or a module and cannot be given to the global hiera (RuntimeError)
        from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera.rb:50:in `initialize'
        from /opt/puppetlabs/puppet/bin/hiera:232:in `new'
        from /opt/puppetlabs/puppet/bin/hiera:232:in `<main>'
edit retag flag offensive close merge delete

Comments

1

disable the version in /etc/puppetlabs/puppet/hiera.yaml -- which is global file, like below #version: 5 your error will be vanished then. Thanks & Regards

Sushil_Rangari gravatar imageSushil_Rangari ( 2018-04-13 02:13:55 -0500 )edit

Use `lookup` instead of `hiera` command line tool. The `hiera` command line tool is deprecated and only understands/works-with hiera 3. The advice to drop the version is wrong - your config file is in the hiera 5 format, and you cannot simply drop the version - you would just get other errors.

Henrik Lindberg gravatar imageHenrik Lindberg ( 2018-04-15 03:20:00 -0500 )edit