Hiera不解决事实

时间:2018-02-19 12:49:38

标签: puppet hiera

我在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和{{1} }。

如果我再次使用os/.yaml运行命令,我可以看到有关包含事实的节点的信息转储:

--debug

Puppet:5.4.0

1 个答案:

答案 0 :(得分:0)

在以下路径中指定事实文件

/etc/facter/facts.d/${your_component_facts}.sh

并提供所需的权限:

chmod +x /etc/facter/facts.d/${your_component_facts}.sh