Hiera recursive lookup problem

104 views
Skip to first unread message

Michele Manzato

unread,
Mar 18, 2022, 12:05:13 PM3/18/22
to Puppet Users
Hi, I've got a problem with Hiera interpolation (lookups). I'm fairly new to Hiera, so I think I am misunderstanding something important, but doc searches revealed nothing so far.

I'm using Puppet 7.x with the following hiera.yaml:

# hiera.yaml
---
version: 5
hierarchy:
- name: "Per-node data"
path: "nodes/%{::trusted.certname}.yaml"
- name: "Per-subsystem data"
path: "subsystems/%{::subsystem}.yaml"
- name: "Common and fallback data"
path: "common.yaml"

Basically, data should be searched first in the node-specific file, then in a subsystem specific file, then in the common file (that is empty, so far).

(bare bones) Agent-specific file looks like this:

# environments/test/data/nodes/agent1.yaml
---
my:
net:
host:
ip_address: "%{lookup('my.net.hosts.agent1')}"
needs_proxy: false

(you see that I use lookup interpolation, that's in order to avoid data duplication).
The my.net.hosts.agent1 key is not part of this file, but is found in the subsystem-specific
yaml:

# environments/test/data/subsystems/main.yaml
---
my:
net:
hosts:
agent01: "192.168.56.6"
    needs_proxy: true

Per the hiera.yaml above it this comes later in the hierarchy.

Unfortunately, the agent fails with the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Lookup of key 'my.net.hosts.agent01' failed: Recursive lookup detected in [my.net.needs_proxy, my.net.hosts.agent01] on node agent1

and I got no clue why that happens, as I can't see any obvious loops.

Any help would be greatly appreciated.

Thanks
Michele

Kenyon Ralph

unread,
Mar 19, 2022, 10:39:14 AM3/19/22
to Puppet Users
Just like the error says, you're trying to do a recursive lookup and you can't do that. You're trying to do a lookup in a key named "my" which contains a lookup for a key named "my".
Reply all
Reply to author
Forward
0 new messages