Ask Your Question
0

hiera.yaml expects array, got struct

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

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 testnode.test.com

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

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

defaults:
    data_hash: yaml_data
datadir: data

and this is my site.pp

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

# Disable filebucket by default for all File resources:
#https://docs.puppet.com/pe/2015.3/release_notes.html#filebucket-resource-no-longer-created-by-default
File { backup => false }

# DEFAULT NODE
# Node definitions in this file are merged with node data from the console. See
# http://docs.puppetlabs.com/guides/language_guide.html#nodes 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': }
  hiera_include('role')
}

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
1

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

jreitmayer gravatar image

Never mind.

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

https://puppet.com/docs/puppet/4.10/h...

Its still not finding my nodes though.

edit flag offensive delete link more

Comments

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 -0500 )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

Stats

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

Seen: 124 times

Last updated: Jun 26