puppet - Puppet 查找找不到层次键值
问题描述
我在我的 puppet 查找调用中看到了这个错误(使用 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 -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
谁能解释为什么我会看到这个错误(对 Puppet 来说相当新)...
解决方案
这是一个文件位置问题。
我有:
▶ 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
请注意,在中引用的目录data
必须相对于您所在的目录。参考:hiera.yaml
defaults.datadir
hiera.yaml
datadir — 保存数据文件的目录;如果您设置默认值,则可以省略。
此路径相对于 hiera.yaml 的目录:如果配置文件位于 /etc/puppetlabs/code/environments/production/hiera.yaml 并且 datadir 设置为 data,则数据目录的完整路径为 /etc/puppetlabs /代码/环境/生产/数据。
在全局层中,您可以选择将 datadir 设置为绝对路径;在其他层中,它必须始终是相对的。
推荐阅读
- php - T_CONSTANT_ENCAPSED_STRING Zoho
- postgresql - NamedNativeQuery JPA 空主键异常
- apache-kafka - 卡夫卡在巨大压力下丢失消息 - 正常吗?
- angular - 有角度的闪存卡 - 组件刷新后不听 eventEmitter
- apache-kafka - Kafka MirrorMaker 2.0 复制每条消息
- formatting - 尝试在地址读取过去的文件结尾
- javascript - 我正在尝试将 Javascript 计算器作为 freecodecamp 任务的一部分,但无法使其与 ID 和数据运算符一起使用
- google-chrome - 我可以让 Cypress 运行 Chrome 的测试版吗?
- sql - 尝试在带有 varchar 的 WHERE 子句中使用 IN 但遇到整理问题
- java - Java 使用 Saxon (s9api) 转换 XML:如何在资源中添加输入文件?