Ask Your Question

hiera doesn't work

asked 2016-06-03 12:47:24 -0600

nobody gravatar image

Hi all! I have puppetmaster 4 + puppetdb 4.1 and i try to use hiera... In puppet master:

puppet nodes # cat /etc/puppetlabs/code/hiera.yaml 
  - yaml
:datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
  - "nodes/%{::trusted.certname}"
  - "nodes/%{::hostname}"
  - common

puppet nodes # cat /etc/puppetlabs/code/environments/production/hieradata/nodes/puppetdb.yaml 
# /etc/puppetlabs/code/production/hieradata/
ntp::autoupdate: false
ntp::enable: true
 - iburst
 - iburst
 - iburst
 - iburst

Why if i run in puppetdb puppet agent -t

Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppetdb
Info: Applying configuration version '1464975833'
Notice: Applied catalog in 0.03 seconds

Nothing happens... Maybe i must do anything else?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-06-03 20:03:52 -0600

DarylW gravatar image

updated 2016-06-03 23:03:07 -0600

You can't entirely drive your configuration from hiera. You need to have a site.pp using a hiera_include('classes') or a node declaring the nodes you wish to run, and hiera will just fill in the values for the parameters of the classes you wish to include.

I would start with the traditional method... Here's the official puppet docs on how to Assign Configuration to nodes

If you want to use hiera as an ENC(External Node Classifier), you can use hierainclude... Here is an example of using hierainclude to load classes into your configuration... assigning-classes-to-nodes-with-hiera-include

Also to clarify... the reason your run 'succeeds' but doesn't do anything is because it is applying an empty catalog, since you haven't actually specified any classes to include.

edit flag offensive delete link more


Hmm, i think if i use hiera, there is no need to use site.pp , all nodes daclares in /etc/puppetlabs/code/environments/production/hieradata/nodes/ - it's not true? :(

nobody gravatar imagenobody ( 2016-06-03 22:25:58 -0600 )edit

Hiera is just a collection of data. in that file, you are defining the values that hiera will supply when the node name matches the name of your file. If you pair it with a 'classes' array, and you list all the classes you need, via my hiera_include link above, you will get the results you want

DarylW gravatar imageDarylW ( 2016-06-03 23:00:53 -0600 )edit

either way, you still need a site.pp that has the hiera_include('classes') call to actually do the class setup

DarylW gravatar imageDarylW ( 2016-06-03 23:01:15 -0600 )edit

Ok, if i create site.pp with *node puppetdb { hiera_include('classes') }* , then in /etc/puppetlabs/code/environments/production/hieradata/nodes/puppetdb.yaml everything will work?

nobody gravatar imagenobody ( 2016-06-04 00:20:22 -0600 )edit

I ran into a similar problem, puppet master v4. hiera_include('classes') is not finding my classes at all. puppet config print hiera_config gives me /etc/puppetlabs/code/hiera.yaml (not /etc/puppetlabs/code/hiera.yaml what you use). symlinking did not help so far. cmdline hiera give ok values !

sandy gravatar imagesandy ( 2016-07-05 10:11:14 -0600 )edit

answered 2016-07-07 07:07:31 -0600

sandy gravatar image

First, about hiera_include('classes'), yes you need that.

Documentation says: The main manifest can be a single file, or a directory containing many files. Here is my working example, using a single, explicit site.pp file:

puppet config print hieraconfig
/etc/puppetlabs/puppet/hiera.yaml # standard, did not change this
... hiera

Make sure you know where you hiera_config is:

puppet config print hiera_config
/etc/puppetlabs/puppet/hiera.yaml # standard, did not change this


cat /etc/puppetlabs/puppet/hiera.yaml

- hostname/%{hostname}
... some more levels... but left it out for clarity...
- default
- yaml

I did NOT set the datadir explicitly, so when running puppet agent -t --environment=development... the /etc/puppetlabs/code/environments/development/hieradata directory is used.

Those 2 files from the hierarchy get evaluated:


In default.yaml, I assign some classes (my own...)

- cron
- dns

And they do get applied when running puppet.

Hope it helps.

edit flag offensive delete link more


Using puppet server 2.4.0, puppetdb 4.1.2 on centos 6.8

sandy gravatar imagesandy ( 2016-07-07 07:09:35 -0600 )edit

sandy, thank you so much, i did it already, and it works fine ^_^

nobody gravatar imagenobody ( 2016-07-12 09:41:18 -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



Asked: 2016-06-03 12:47:24 -0600

Seen: 759 times

Last updated: Jul 07 '16