Ask Your Question

Declaring classes with Hiera and Site.pp on Puppet Enterprise?

asked 2014-08-22 18:33:14 -0500

mtravis gravatar image

I have a fresh install of Puppet Enterprise with 2 nodes. When I have hiera_include in site.pp it will not assign the classes that I have in hiera. But if I assign the class via the Puppet Dashboard it works on the node. I am fairly new to Puppet and I'm hoping that's it's just a configuration that I missed. I thought site.pp and the dashboard merged classes as long as the class wasn't declared in site.pp and the dashboard?


Then for the node I have in it's yaml file the following:
- nginx

edit retag flag offensive close merge delete


What version of PE? What does your hierarchy (from `$confdir/hiera.conf`) look like? Are you using environments?

llowder gravatar imagellowder ( 2014-08-22 21:49:59 -0500 )edit

- node/%{::fqdn}
- "environment/%{environment}"
- global

Puppet Enterprise 3.3.1
Yes I want to implement environments.

mtravis gravatar imagemtravis ( 2014-08-22 23:35:20 -0500 )edit

I have discovered that it is a problem with the yaml files. I get Error:
Could not retrieve catalog from remote server: Error 400 on SERVER: Hiera type mismatch: expected Array and got NilClass

mtravis gravatar imagemtravis ( 2014-08-23 02:13:29 -0500 )edit

With more testing I found that the hiera.yaml hiearchy for - node/%{::fqdn} does not work. These are the variations that I have tried:
- "%{::clientcert}"
- "%{::fqdn}"
- %{fqdn}"
- %fqdn
Hiera version: 1.3.3 Facter version: 1.7.5

Adding the classes to the global.yaml file and everything works fine. It's only when I try to add facts to the hierarchy is where I run into problems

mtravis gravatar imagemtravis ( 2014-08-23 02:40:05 -0500 )edit

My recommendation here to use json instead of yaml. I read somewhere that yaml will be not supported in puppet in the future. I can't find the link though.

louis gravatar imagelouis ( 2014-08-26 09:08:03 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-08-26 04:07:18 -0500

spend gravatar image

I can only think you have the file name/paths wrong, incorrect permissions or mistaking merge behaviour.


hiera.yaml :hierarchy: - "%{fqdn}" - 'global'

(or - "node/%{fqdn}" hard to tell which you're trying to use from your post ~ this would require [datadir]/node/[fqdn].yaml )

copy global.yaml to the fqdn.yaml in your datadir, and ensure it has correct ownership / perms, make the changes you require to test.

When testing make sure you are looking for unique results rather than merged data, and the yaml file syntax is OK.

edit flag offensive delete link more


I noticed my formatting was wrong. I did not have double quotes around %{fqdn}

mtravis gravatar imagemtravis ( 2014-08-26 22:24:19 -0500 )edit

answered 2014-08-26 12:07:49 -0500

WhatsARanjit gravatar image

Run the following to see where hiera is looking on the master:

# hiera -y $(puppet agent --configprint vardir)/yaml/facts/certname.yaml classes --debug

That will show you how hiera is traversing your hierarchy and give you an idea what it is doing. Replace certname with the proper value.

edit flag offensive delete link more

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: 2014-08-22 18:33:14 -0500

Seen: 407 times

Last updated: Aug 26 '14