Ask Your Question

how to use custom facts in hiera hierarchy

asked 2013-11-28 09:39:10 -0600

mponjevic gravatar image

updated 2013-11-28 12:05:21 -0600

Stefan gravatar image

I defined my hierarchy like this:

  - yaml
  - puppet
  - node/%{fqdn}
  - role/%{myrole}
  - subenvironment/%{subenv}
  - domain/%{domain}
  - common
  :datadir: /etc/puppetlabs/hiera

if I define classes in node or domain tree, that works but node for role or subenvironment tree. It seems to be hiera does not know about custom facts %{subenv} and %{myrole} for some reason.

On agent node I can see these custom facts with facter -p, but not with facter command. When I run puppet agent -t I can see :

info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/subenv.rb
Info: Loading facts ...
edit retag flag offensive close merge delete


probably a stupid question, but have you restarted your puppet master after making changes to your hierarchy?

Stefan gravatar imageStefan ( 2013-11-28 12:08:41 -0600 )edit

I did restarted puppet master, even rebooted box.

mponjevic gravatar imagemponjevic ( 2013-11-29 03:09:18 -0600 )edit

more info puppet --version 3.3.1 (Puppet Enterprise 3.1.0) Both master and agent nodes are the same version. It’s not quoting btw. Also on agent node ...(more)

mponjevic gravatar imagemponjevic ( 2013-11-29 03:57:14 -0600 )edit

The behaviour of 'facter' and 'facter' -p is as defined. The command 'facter' used standard facts and (since v1.6?) loads from files in /etc/facter/facts.d. Only 'facter ...(more)

Richard Berwald gravatar imageRichard Berwald ( 2013-12-01 07:39:33 -0600 )edit

Thanks Richard, I ran the command you suggested and it seems to me it opens right files, so it looks like on master hiera hierarchy works: # hiera -d -c /etc ...(more)

mponjevic gravatar imagemponjevic ( 2013-12-02 04:31:24 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-10-01 04:17:14 -0600

jorhett gravatar image

Requestor figured out the answer for himself. Reposting for posterity for anyone else seeking the answer, and to show this question as answered:

Custom facts should not have a linefeed in the value if you plan to use them in the hiera hierarchy (or any other file path)

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



Asked: 2013-11-28 09:39:10 -0600

Seen: 3,227 times

Last updated: Oct 01 '15