cclloyd
cclloyd

Reputation: 9195

The Lookup Configuration at hiera.yaml has wrong type, entry 'hierarchy' index 0 expects a Struct value, got String

This setup worked before, but after reinstalling Ubuntu 16.04 on my server and reinstalling puppetserver and puppet agent, I'm getting an error when trying to do my first agent run.

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'lookup_options' failed: The Lookup Configuration at '/etc/puppetlabs/puppet/hiera.yaml' has wrong type, entry 'hierarchy' index 0 expects a Struct value, got String

The Lookup Configuration at '/etc/puppetlabs/puppet/hiera.yaml' has wrong type, entry 'hierarchy' index 1 expects a Struct value, got String

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' (file: /etc/puppetlabs/code/environments/production/site.pp, line: 1, column: 1) on node cclloyd.com

/etc/puppetlabs/puppet/hiera.yaml:

---
# Hiera 5 Global configuration file

version: 5

:backends:
  - yaml
:hierarchy:
  - "nodes/%{::trusted.certname}"
  - common

:yaml:
  :datadir:

Upvotes: 1

Views: 3803

Answers (1)

John Bollinger
John Bollinger

Reputation: 180058

Other than the

version: 5

, your file appears to be in Hiera 3 format. Hiera 3 might plausibly ignore the 'version' key and handle the rest normally, but evidently you are now running Hiera 5. Inasmuch as the file declares itself to be in Hiera 5 format, it is natural that Hiera takes it at its word. An Hiera 5 analog of that config would look more like this:

---
# Hiera 5 Global configuration file

version: 5

hierarchy:
  - name: "Per-node data (yaml version)"
    path: "nodes/%{::trusted.certname}"
  - name: "Common and fallback data"
    path: "common.yaml"

defaults:
  data_hash: yaml_data

Note that the value of the 'hierarchy' key is an array of hashes, and that (in Hiera 5) it should be 'hierarchy', not ':hierarchy'.

Alternatively, Hiera 5 might accept your original file if you simply change it to specify the correct config file version (3) for the original contents. Inasmuch as Hiera 3 format is deprecated in Puppet 5 and scheduled for removal in Puppet 6, however, this seems like it would be a good time to convert to the new syntax.

Upvotes: 3

Related Questions