Ask Your Question

hiera.yaml expects array, got struct

asked 2018-06-26 11:03:26 -0600

jreitmayer gravatar image

Hey all,

New to puppet enterprise but trying to migrate an old puppet open source to PE and have been struggling with hiera. Maybe y'all can help...

I get this error on my test node when i try to run puppet agent -t --noop.

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, The Lookup Configuration at '/etc/puppetlabs/code/environments/production/hiera.yaml' has wrong type, entry 'hierarchy' expects an Array value, got Struct (file: /etc/puppetlabs/code/environments/production/manifests/site.pp, line: 45, column: 3) on node

Now, i'm a sys admin and I don't know much about yaml or writing their code. Maybe someone can help me a bit.

Here is my heira.yaml...

version: 5

  #  name: "Per-node data" 
    path: "nodes/%{trusted.certname}.yaml"
  #  name: "Per-OS defaults"
    path: "os/%{operatingsystem}.yaml"
  #  name: "Common Data"
    path: "common.yaml"

    data_hash: yaml_data
datadir: data

and this is my site.pp

## site.pp ##
## Active Configurations ##

# Disable filebucket by default for all File resources:
File { backup => false }

# Node definitions in this file are merged with node data from the console. See
# for more on
# node definitions.

# The default node definition matches any node lacking a more specific node
# definition. If there are no other nodes in this file, classes declared here
# will be included in every node's catalog, *in addition* to any classes
# specified in the console for that node.

node default {
  # This is where you can declare classes for all nodes.
  # Example:
  #   class { 'my_class': }

My site.pp is in my puppet controlrepo on Github located under manifests. hiera.yaml is on the top. I am trying to get my test node to pull its configs from controlrepo/data/nodes/testnode.yaml. I have another folder in controlrepo/data/os that has a CentOS.yaml file for a bunch of other stuff.

I appreciate any help. Thanks Jeff

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-26 11:17:15 -0600

jreitmayer gravatar image

Never mind.

I solved it by looking at the docs... hiera.yaml needs a - to make the array work

Its still not finding my nodes though.

edit flag offensive delete link more


I find it helpful to use ruby or something else to turn my yaml into json to inspect it - it makes the hash / array structure more obvious to me (someone who is less familiar with YAML)

DarylW gravatar imageDarylW ( 2018-06-27 11:48:16 -0600 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2018-06-26 11:02:52 -0600

Seen: 278 times

Last updated: Jun 26