1

I have a puppet master (version 3.8.1) set up, with a hiera.yaml file which I think is set up correctly, like so:

pete@ip-172-31-4-61:~$ cat /etc/puppet/hiera.yaml
---
:hierarchy:
    - "%{::fqdn}"
:backends:
    - yaml
:yaml:
    :datadir: '/etc/puppet/hieradata'

When I run the following command:

sudo puppet master --verbose --debug --compile ip-10-1-3-7

(ip-10-1-3-7 is one of my nodes) I do not see any information in the catalog based on my hiera data. Even more confusing is I do not see this line in the debug:

Debug: hiera(): Hiera YAML backend starting

Which I do see in other puppet masters I have that do work with Hiera

UPDATE: I have edited my puppet.conf file to include hiera_config as per the comments below, and restarted puppetmaster but it still does not work.

pete@ip-172-31-4-61:~$ cat /etc/puppet/puppet.conf
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
certname = master
dns_alt_names = puppet
hiera_config = $confdir/hiera.yaml

[master]
# These are needed when the puppetmaster is run by passenger
# and can safely be removed if webrick is used.
ssl_client_header = SSL_CLIENT_S_DN
ssl_client_verify_header = SSL_CLIENT_VERIFY

I am running Ubuntu 14.04, with the package repo from puppetlabs:

pete@ip-172-31-4-61:~$ cat /etc/issue
Ubuntu 14.04.2 LTS \n \l

pete@ip-172-31-4-61:~$ dpkg -l "puppet*"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                        Version            Architecture       Description
+++-===========================-==================-==================-============================================================
rc  puppet                      3.8.1-1puppetlabs1 all                Centralized configuration management - agent startup and com
ii  puppet-common               3.8.1-1puppetlabs1 all                Centralized configuration management
un  puppet-el                   <none>             <none>             (no description available)
un  puppetdb-terminus           <none>             <none>             (no description available)
ii  puppetlabs-release          1.0-11             all                "Package to install Puppet Labs gpg key and apt repo"
un  puppetlabs-release-devel    <none>             <none>             (no description available)
rc  puppetlabs-release-pc1      0.9.2-1trusty      all                Release packages for the Puppet Labs PC1 repository
ii  puppetmaster                3.8.1-1puppetlabs1 all                Centralized configuration management - master startup and co
ii  puppetmaster-common         3.8.1-1puppetlabs1 all                Puppet master common scripts

UPDATE: Layout of hieradata dir:

pete@ip-172-31-4-61:~$ tree /etc/puppet/hieradata
/etc/puppet/hieradata
└── ip-10-1-3-7.yaml

Contents of hiera node file:

pete@ip-172-31-4-61:~$ cat /etc/puppet/hieradata/ip-10-1-3-7.yaml
---
classes:
  - nginx

nginx::nginx_upstreams:
  'app':
    ensure: present
    members:
      - localhost:5000
  'site':
    ensure: present
    members:
      - site.my-app.com

nginx::nginx_vhosts:
  'localhost':
    proxy: 'http://site'
    proxy_read_timeout: '5'

nginx::nginx_locations:
  app:
    location: '~ "^/(members|login|logout)"'
    vhost: localhost
    proxy: 'http://app'
    proxy_read_timeout: '20'
    ssl: false
    location_cfg_append:
      proxy_set_header:
        - 'X-Forwarded-Host $http_host'

I am reasonably confident it is not to do with the hieradata node files as even on another puppet master where there is no node file for the host, I still get the Debug: hiera(): Hiera YAML backend starting debug line.

  • What's set up in your puppet.conf? – Shane Madden Jul 14 '15 at 18:04
  • Have you defined path to your hiera config hiera_config = $confdir/hiera.yaml in puppet.conf? – chetangb Jul 14 '15 at 18:37
  • Share the layout of your hieradata dir + contents of your node file. – fuero Jul 16 '15 at 6:06
  • @chetangb, is $confdir automatically defined? If not it may need to be defined manually. This may be a coincidence/unimportant but based on the IPs the two nodes you are using are on two separate subnets, 172.31.4.61 and 10.1.3.7. is it safe to assume you have setup appropriate routing table entries so the nodes on different networks can communicate, services are listening on appropriate ports+IPs and the firewall, ACLs,etc have been configured correctly to allow access between the networks? – Matt Jul 21 '15 at 17:10
  • @chetangb: I removed $confdir and set an absolute path but still no luck. The master is on a public IP but the node has access to it through a NAT device - I have checked a puppet run on the client - it just completes with nothing applied – cubabit Jul 21 '15 at 17:15
3
+100

Verify that this line is in your site.pp:

hiera_include('classes')

Then try running this command:

puppet master --compile host.domain.tld --debug 2>&1 | grep hiera

This should give you output like this:

Debug: hiera(): Hiera YAML backend starting
[...]
Debug: hiera(): Looking up $KEY in YAML backend
Debug: hiera(): Looking for data source common
Debug: hiera(): Looking for data source node/host.domain.tld
Debug: hiera(): Found $KEY in node/host.domain.tld

Running the command above without the | grep part should give you something like that too:

Debug: importing '/etc/puppet/environments/production/modules/xxx/manifests/init.pp' in environment production

proving that classes are being loaded.

The data you shared doesn't make clear if any classes are assigned to the client, so if there's no class loaded, no implicit hiera lookups.

Here's a sample from my puppet master:

Info: Not using expired facts for host.corp from cache; expired at 2015-07-21 19:42:37 +0200
Info: Caching facts for host.corp
Info: Caching node for host.corp
Debug: hiera(): Hiera YAML backend starting
Debug: hiera(): Looking up classes in YAML backend
Debug: hiera(): Looking for data source kernel/Linux
Debug: hiera(): Found classes in kernel/Linux
Debug: hiera(): Looking for data source osfamily/RedHat
Debug: hiera(): Looking for data source os/CentOS
Debug: hiera(): Found classes in os/CentOS
Debug: hiera(): Looking for data source node/host.corp
Debug: hiera(): Found classes in node/host.corp
Debug: hiera(): Looking for data source common
Debug: hiera(): Found classes in common
Debug: hiera(): Looking for data source corp

Try debugging hiera itself too (sample here is lookup up a string value with -c):

hiera --debug -c /etc/puppet/hiera.yaml "sample::foo" bla "::fqdn=host.corp" osfamily='RedHat' "::environment=production"
DEBUG: 2015-07-22 16:49:20 +0200: Hiera YAML backend starting
DEBUG: 2015-07-22 16:49:20 +0200: Looking up sample::foo in YAML backend
DEBUG: 2015-07-22 16:49:20 +0200: Looking for data source node/host.corp
DEBUG: 2015-07-22 16:49:20 +0200: Found sample::foo in node/host.corp
bar

Also, check with facter -p if the values supplied by your node are correct.

  • I thought this fixed it but I don't think it has – cubabit Jul 22 '15 at 14:14
  • I made sure that line was in my site.pp file, but after a puppetmaster restart I still get no 'Debug: hiera(): Hiera YAML backend starting' – cubabit Jul 22 '15 at 14:31
  • Thanks - you did in fact help me fix it. It was that the 'hiera_include' was missing from my site.pp file. The thing that threw me is that the hiera backend does not start unless I run puppet master as root – cubabit Jul 22 '15 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.