在我的木偶查找调用(使用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'尝试直接的hiera查找是有效的:
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我的hiera.yaml文件(位于/etc中):
---
version: 5
hierarchy:
- name: Common
path: common.yaml
defaults:
data_hash: yaml_data
datadir: data我的common.yaml文件(位于/var/lib/hiera中):
---
foo: bar有谁能解释我为什么会看到这个错误(对木偶来说很新).
发布于 2019-01-16 14:10:13
这是一个文件位置问题。
我有:
▶ cat spec/fixtures/hiera/hiera.yaml
---
version: 5
hierarchy:
- name: Common
path: common.yaml
defaults:
data_hash: yaml_data
datadir: data结构:
▶ tree spec/fixtures/hiera
spec/fixtures/hiera
├── data
│ └── common.yaml
└── hiera.yaml命令行:
▶ puppet lookup --hiera_config=spec/fixtures/hiera/hiera.yaml foo
--- bar注意,在hiera.yaml中引用的defaults.datadir目录必须相对于您的hiera.yaml所在的目录。参考
datadir -保存数据文件的目录;如果设置默认值,可以省略该目录。 这个路径相对于erra.yaml的目录:如果配置文件位于/etc/puppetlabs/code/environments/production/hiera.yaml,而datadir设置为data,则数据目录的完整路径为/etc/puppetlabs/code/environments/production/data. 在全局层中,可以选择将datadir设置为绝对路径;在其他层中,它必须始终是相对的。
https://stackoverflow.com/questions/54216626
复制相似问题