Ask Your Question

Custom facts in hiera hierachy not working in CentOS 7

asked 2016-10-06 23:01:54 -0600

Noodles gravatar image

I'm trying to debug a problem where the custom facts from a node are not being used correctly when looking for hiera data. This is my hiera.yaml file:

  - eyaml
  - yaml
  - "nodes/%{::trusted.certname}"
  - "role/%{::instance_role}"
  - "environments/%{::environment}"
  - certs
  - common

# datadir is empty here, so hiera uses its defaults:
# - /etc/puppetlabs/code/environments/%{environment}/hieradata on *nix
# - %CommonAppData%\PuppetLabs\code\environments\%{environment}\hieradata on Windows
# When specifying a datadir, make sure the directory exists.

When I use this with a CentOS 6 node (vagrant box) and /opt/puppetlabs/facter/facts.d/instance_role.txt is set to:


This works fine. However with the same setup on CentOS 7 (vagrant box) it gives:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find data item haproxy::listen in any Hiera data file and no default supplied at /etc/puppetlabs/code/environments/dev/site/profile/manifests/haproxy.pp:41:40 on node

If I change "role/%{::instance_role}" to "role/web" in hiera.yaml, then that works fine, but it doesn't look like puppet is passing on the custom fact on CentOS 7.

Using puppet 4.7.0, hiera 3.2.1, facter 3.4.1

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-10-06 23:21:42 -0600

Noodles gravatar image

updated 2016-10-09 17:10:21 -0600

So the solution was to move the custom fact to /etc/puppetlabs/facter/facts.d/instance_role.txt

There was also an issue with new line characters (vagrant box was being created on a Windows machine). Once the instance_role.txt was updated to a unix new line characters then it worked as expected.

edit flag offensive delete link more

answered 2016-10-07 02:52:08 -0600

lupin gravatar image

You either make that into executable fact, ie that will output a key=value pair. Or create a structured one using yaml, ie. instacerole.yaml with instance_role: web content.

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: 2016-10-06 23:01:54 -0600

Seen: 148 times

Last updated: Oct 09 '16