Reputation: 1624
I'm seeing this error with my puppet lookup call (basic test using hiera):
puppet lookup --explain foo
Searching for "lookup_options"
Global Data Provider (hiera configuration version 5)
No such key: "lookup_options"
Searching for "foo"
Global Data Provider (hiera configuration version 5)
No such key: "foo"
Function lookup() did not find a value for the name 'foo'
Trying a direct hiera lookup works:
hiera -d foo
DEBUG: 2019-01-16 11:53:39 +0000: Hiera YAML backend starting
DEBUG: 2019-01-16 11:53:39 +0000: Looking up foo in YAML backend
DEBUG: 2019-01-16 11:53:39 +0000: Looking for data source common
DEBUG: 2019-01-16 11:53:39 +0000: Found foo in common
bar
My hiera.yaml file (located in /etc):
---
version: 5
hierarchy:
- name: Common
path: common.yaml
defaults:
data_hash: yaml_data
datadir: data
My common.yaml file (located in /var/lib/hiera):
---
foo: bar
Can anyone explain why I'm seeing this error (fairly new to Puppet) ...
Upvotes: 2
Views: 3813
Reputation: 15502
It is a file location problem.
I have:
▶ cat spec/fixtures/hiera/hiera.yaml
---
version: 5
hierarchy:
- name: Common
path: common.yaml
defaults:
data_hash: yaml_data
datadir: data
Structure:
▶ tree spec/fixtures/hiera
spec/fixtures/hiera
├── data
│ └── common.yaml
└── hiera.yaml
Command line:
▶ puppet lookup --hiera_config=spec/fixtures/hiera/hiera.yaml foo
--- bar
Note that the data
directory as referenced in hiera.yaml
in defaults.datadir
must be relative to the directory your hiera.yaml
is in. Ref:
datadir — The directory where data files are kept; can be omitted if you set a default.
This path is relative to hiera.yaml’s directory: if the config file is at /etc/puppetlabs/code/environments/production/hiera.yaml and the datadir is set to data, the full path to the data directory is /etc/puppetlabs/code/environments/production/data.
In the global layer, you can optionally set the datadir to an absolute path; in the other layers, it must always be relative.
Upvotes: 3