Custom Facts are not working with hiera on puppet agent nodes

asked 2017-03-29 07:48:58 -0500

virenderdubey gravatar image

We have created a custom factor "datacenter" via <modulename>/lib/facter/datacenter.rb on puppet master node. when i ran facter -p datacenter, it works fine, and so added the same in hiera.yaml.

  - yaml
  - "nodes/%{::trusted.certname}"
  - "%{::datacenter}"
  - "%{::osfamily}"
  - 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 ran "puppet agent -t" on puppet master it runs fine.. and picked the hiera parameter value from <datacentervalue>.yaml, but when we ran the same "puppet agent -t" on agent nodes, it fails, with the error " could not find data item in any of the hiera file" Can someone please help to debug this...

edit retag flag offensive close merge delete



Is your custom fact being sent via 'pluginsync' to your agent nodes? That is where the values for the fact need to exist, the facts are synced to agents via pluginsync, then the results are sent back to the master for catalog complication (and hiera data lookup).

DarylW gravatar imageDarylW ( 2017-03-29 10:21:03 -0500 )edit

I believe pluginsync is by default enabled in puppet 4, However our custom facter is present in this directory location on all agents nodes. /opt/puppetlabs/puppet/cache/lib/facter/datacenter.rb.

virenderdubey gravatar imagevirenderdubey ( 2017-04-03 00:59:06 -0500 )edit