我在使用Puppet和Hiera时遇到了一些麻烦,因为Hiera似乎没有使用我在模板中要求的事实。
我有一个/etc/puppetlabs/puppet/hiera.yaml文件,其中包含一个简单的示例层次结构:
---
version: 5
defaults:
datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata"
data_hash: yaml_data
hierarchy:
- name: "Per-node data"
path: "nodes/%{trusted.certname}.yaml"
- name: "Per-OS defaults"
path: "os/%{facts.os.family}.yaml"
- name: "Common data"
path: "common.yaml"然后我有一个傀儡代理,它已经运行并将它的事实发送给Puppet。当我在它上面测试一个查找时,所有的变量都扩展为空字符串:
> puppet lookup profiles --environment production --node puppet.example.local --explain
Searching for "lookup_options"
Global Data Provider (hiera configuration version 5)
Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
Merge strategy hash
Hierarchy entry "Per-node data"
Path "/etc/puppetlabs/code/environments/production/hieradata/nodes/test-.yaml"
Original path: "nodes/test-%{trusted.certname}.yaml"
Path not found
Hierarchy entry "Per-OS defaults"
Path "/etc/puppetlabs/code/environments/production/hieradata/os/.yaml"
Original path: "os/%{facts.os.family}.yaml"
Path not found
Hierarchy entry "Common data"
Path "/etc/puppetlabs/code/environments/production/hieradata/common.yaml"
Original path: "common.yaml"
No such key: "lookup_options"
Searching for "profiles"
Global Data Provider (hiera configuration version 5)
Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
Hierarchy entry "Per-node data"
Path "/etc/puppetlabs/code/environments/production/hieradata/nodes/.yaml"
Original path: "nodes/test-%{trusted.certname}.yaml"
Path not found
Hierarchy entry "Per-OS defaults"
Path "/etc/puppetlabs/code/environments/production/hieradata/os/.yaml"
Original path: "os/%{facts.os.family}.yaml"
Path not found
Hierarchy entry "Common data"
Path "/etc/puppetlabs/code/environments/production/hieradata/common.yaml"
Original path: "common.yaml"
No such key: "profiles"
Function lookup() did not find a value for the name 'profiles'没有找到值,但我认为这是无关紧要的,因为它甚至不寻找任何真正的文件,这些文件都显示为nodes/.yaml和os/.yaml。
如果我使用--debug再次运行该命令,我可以看到有关节点的信息转储,其中包括事实:
Debug: Facter: fact "osfamily" has resolved to "RedHat".
...
Debug: Facter: fact "os" has resolved to {
architecture => "x86_64",
family => "RedHat",
hardware => "x86_64",
name => "CentOS",
release => {
full => "7.4.1708",
major => "7",
minor => "4"
},木偶: 5.4.0
发布于 2019-06-27 19:05:26
在以下路径中指定事实文件
/etc/facter/facts.d/${your_component_facts}.sh并授予所需的权限:
chmod +x /etc/facter/facts.d/${your_component_facts}.shhttps://stackoverflow.com/questions/48866625
复制相似问题