1

I'm trying to set up a new node using puppet, but it fails with an error that leads me to believe that hiera isn't finding the correct datasource:

Server Error: Evaluation Error: Error while evaluating a Function Call, undefined method `empty?' for nil:NilClass at ${line 4 in some selfwritten class}

I also got this error, but I don't remember what I changed (if anything) that resulted in it:

Server Error: Evaluation Error: Error while evaluating a Function Call, Unknown alias: 3B4007E7596ADF847ECA510D57069DBF2B3DB006 at ${line 4 in the same selfwritten class}

The line in the class that puppet complains about looks like this:

$network = hiera("network")

This is the first line in the class. This same lookup works on a different node.

My /etc/puppetlabs/puppet/hiera.yaml looks like this

---
:backends:
  - yaml
:hierarchy:
  - "nodes/%{::trusted.certname}"
  - "customer/%{customer}"
  - "preview/%{preview}"
  - "test/%{test}"
  - common

:yaml:
# 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.
  :datadir:

This new node has in its manifest

$customer='foo'

While the working node has

$customer='bar'

I have a yaml file for each, and yamllint shows neiter errors nor warnings for hiera.yaml or the two below.

ls /etc/puppetlabs/code/environments/production/hieradata/customer/

foo.yaml    bar.yaml

The first line in their respective yaml file defines a string for this value network:

network: "172.28.11"

I've tried using puppet lookup to debug this issue, so far without success

puppet lookup --environment production --debug --explain --node foo-app1.domain.tld --compile network 

<snip lots of unrelated stuff>
Debug: hiera(): Looking for data source customer/foo
Error: Could not run: Evaluation Error: Error while evaluating a Function Call, Unknown alias: 3B4007E7596ADF847ECA510D57069DBF2B3DB006 at {same class and line}

If I run that command without --compile it quits without error, but also without looking up the customer datasource

  • All nodes are running Debian Jessie (8)
  • The Puppetserver is version 2.5.0 from the official Puppetlabs Repo for Jessie
  • I've tried the puppet agent version from Jessie (3.7.2) and from Backports (4.8.2) - no difference

So: Why is this node failing the hiera lookup? How do I fix it? How do I correctly use puppet lookup to fetch this value from the working node? (to aid in debugging)

  • I'm wondering if the problem is being triggered by some *other* entries in hiera (perhaps doing a custom function lookup that is hitting a bad state?) that is in the lookup search path that hiera is following for the problem node (perhaps in the node-specific YAML in hieradata/nodes/) – Craig Miskell Aug 12 '17 at 22:34
  • I can pretty much guarantee that's not the case. I've commented out every other class in this node's manifest, this is the only hiera lookup, and there are no node-specific YAML files. – Christoph Gösgens Aug 14 '17 at 09:26
  • Have you checked the obvious stuff like file permissions on `foo.yaml`? Is it definitely `.yaml` and not `.yml`, and does it have/need the `---` at the top of the file? – shearn89 Aug 14 '17 at 10:14

0 Answers0