Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5

3,431 views
Skip to first unread message

Joshua Schaeffer

unread,
Feb 6, 2017, 3:08:28 PM2/6/17
to Puppet Users
I recently destroyed my puppetserver server and recreated it in my sandbox environment. Before I destroyed it, I copied all my important data off of the server including my /etc/puppetlabs/code/hiera.yaml file.

When I recreated my server and set everything back up I copied all my modules, configuration files, the hiera.yaml file, etc back over to the new server. Everything runs fine still and all my modules still work, but now I get this warning:

root@fenix:/etc/puppetlabs/code/environments/sandbox# puppet apply --environment sandbox ./manifests/
Warning: /etc/puppetlabs/code/hiera.yaml: Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5
   
(in /etc/puppetlabs/code/hiera.yaml)
Warning: Undefined variable 'facts.fqdn';
   
(file & line not available

Here is my hiera.yaml file:

---
:backends:
 
- yaml
:hierarchy:
 
- "fqdn/%{facts.fqdn}"
 
- "os/%{facts.osfamily}"
 
- common
:yaml:
 
:datadir: /etc/puppetlabs/code/environments/%{::environment}/hieradata


This is the exact same file I was using before I destroyed my old puppetserver server and I wasn't getting this warning (same versions and everything). I've done a bit of searching but can't find anything on upgrading 'hiera.yaml' from version 3 to version 5. I even copied one of the hiera.yaml example files from the puppet documentation and I still get a warning:

---
:backends:
 
- yaml
:yaml:
 
:datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
:hierarchy:
 
- "nodes/%{::trusted.certname}"
 
- "virtual/%{::virtual}"
 
- "osfamily/%{::osfamily}"
 
- common

root@fenix:/etc/puppetlabs/code/environments/sandbox# puppet apply --environment sandbox ./manifests/
Warning: /etc/puppetlabs/code/hiera.yaml: Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5
   
(in /etc/puppetlabs/code/hiera.yaml)
Warning: Undefined variable '::trusted.certname';
   
(file & line not available)
Warning: Undefined variable 'trusted.certname';
   
(file & line not available)
Notice: Compiled catalog for fenix.harmonywave.com in environment sandbox in 0.49 seconds
Notice: Processing catalog from the sandbox environment.
Notice: /Stage[main]/Main/Notify[UsingSandbox]/message: defined 'message' as 'Processing catalog from the sandbox environment.'
Notice: Applied catalog in 0.53 seconds

Any suggestions would be appreciated.

Thanks,
Joshua

Thomas Müller

unread,
Feb 6, 2017, 4:37:37 PM2/6/17
to Puppet Users
This is a new deprecation introduced with puppet 4.9.0 (puppet-agent 1.9.0).

A related bug: https://tickets.puppetlabs.com/browse/PUP-7171

I too can't find docs to the new format .

- Thomas

Message has been deleted

Joshua Schaeffer

unread,
Feb 7, 2017, 2:25:58 PM2/7/17
to Puppet Users
So going through the ticket it looks like I should be putting "version: 5" in the YAML file and that keys are not prefixed with a colon. But I get errors when I make changes to my hiera.yaml file:

---
version
: 5
backends
: yaml
hierarchy
:

  
- "fqdn/%{facts.fqdn}"
  
- "os/%{facts.osfamily}"
  
- common
yaml
:  datadir: /etc/puppetlabs/code/environments/%{::environment}/hieradata

Here are the errors I get:

root@fenix:/etc/puppetlabs/code/environments/sandbox# puppet apply --environment sandbox ./manifests/
Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'classes' failed:  The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, entry 'hierarchy' index 0 expects a Struct value, got String
  
The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, entry 'hierarchy' index 1 expects a Struct value, got String
  
The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, entry 'hierarchy' index 2 expects a Struct value, got String
  
The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, unrecognized key 'backends'
  
The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, unrecognized key 'yaml' in  The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, entry 'hierarchy' index 0 expects a Struct value, got String
  
The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, entry 'hierarchy' index 1 expects a Struct value, got String
  
The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, entry 'hierarchy' index 2 expects a Struct value, got String
  
The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, unrecognized key 'backends'  The Lookup Configuration at '/etc/puppetlabs/code/hiera.yaml' has wrong type, unrecognized key 'yaml' at /etc/puppetlabs/code/environments/sandbox/manifests/hieraclasses.pp:6:1 on node fenix.harmonywave.co

Clearly the types have changed. However, if hierarchy now expects a Struct, what is the key that should be used? If anybody has information and/or documentation on the new format could you please point me to that.

Thanks,
Joshua

Joshua Schaeffer

unread,
Feb 7, 2017, 2:37:32 PM2/7/17
to Puppet Users
Okay I see that they are actually preparing to release Puppet 4.9.2 which is supposed to fix these issues. Does this mean they will release a new puppet-agent package part of the PC1? Where can I go to track the progress of this minor release?

Bob

unread,
Feb 14, 2017, 12:22:52 PM2/14/17
to Puppet Users
I found that although that fixed my error, I got no data.

Turns out this is because you need a hiera.yaml in each environment folder with the datadir specified to that environment (if you are using a hieradata folder specific to each environment.

I also needed to change puppet.conf and add environment_data_provider = hiera

Bob

unread,
Feb 14, 2017, 12:22:53 PM2/14/17
to Puppet Users


On Wednesday, February 8, 2017 at 8:37:32 AM UTC+13, Joshua Schaeffer wrote:

Bob

unread,
Feb 14, 2017, 12:23:02 PM2/14/17
to Puppet Users
Being that I have followed the default structure this time the following worked fine for me direct from the above link -

---
version: 5

defaults:
  datadir: data
  data_hash: yaml_data

hierarchy:
  - name: "Nodes"
    path: "nodes/%{trusted.certname}.yaml"

  # Putting a JSON level between YAML levels like this
  # was impossible in the old format.
  - name: "Exported JSON nodes"
    data_hash: json_data
    paths:
      # Puppet checks these in order. Even though this is a single
      # item in the hierarchy, it acts like multiple hierarchy levels.
      - "nodes/%{trusted.certname}.json"
      - "insecure_nodes/%{facts.fqdn}.json"

  - name: "Virtualization platform"
    path: "virtual/%{facts.virtual}.yaml"

  - name: "Common defaults"
    path: "common.yaml"


On Wednesday, February 8, 2017 at 8:37:32 AM UTC+13, Joshua Schaeffer wrote:

Eric Sorenson

unread,
Feb 15, 2017, 3:10:26 PM2/15/17
to Puppet Users
Hey, it looks like everyone found this, but I wanted to add that we updated this document with the hiera.yaml v5 format late last week, so if you were looking for it outside of the google doc, it's up and running.

https://docs.puppet.com/puppet/4.9/lookup_quick.html#there-are-two-hierayaml-formats-now

This is an interim update while the docs team work on the full update, which will be out in the next week or two.

--eric0
Reply all
Reply to author
Forward
0 new messages