[英]Puppet lookup fails to find hiera key value
我的人偶查找呼叫(使用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設置為絕對路徑。 在其他層中,它必須始終是相對的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.