Puppet Hiera 5查找函数值

Puppet Hiera 5查找函数值,puppet,hiera,Puppet,Hiera,我正在我的系统中测试这篇博客文章的最后一个示例。我的lookup命令给出了不同的结果。我想知道为什么 对于这个lookup命令,他得到了这个值 % puppet lookup --environmentpath environments classifier::classes --- - sysadmins - nagios - webserver 这是我的配置: # cat /etc/puppetlabs/puppet/hiera.yaml version: 5 defaults: d

我正在我的系统中测试这篇博客文章的最后一个示例。我的lookup命令给出了不同的结果。我想知道为什么

对于这个lookup命令,他得到了这个值

% puppet lookup --environmentpath environments classifier::classes
---
- sysadmins
- nagios
- webserver
这是我的配置:

# cat /etc/puppetlabs/puppet/hiera.yaml
version: 5
defaults:
  datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
  data_hash: yaml_data
hierarchy:
   - name: "Other YAML hierarchy levels"
     paths:
        - "groups/%{facts.hostname}.yaml"
        - "os/%{facts.os.family}.yaml"
        - "common.yaml"
数据文件:

# cat "/etc/puppetlabs/code/environments/production/hieradata/groups/webserver.yaml"
classifier::classes:
  - nagios
  - --sensu
  - webserver

cat "/etc/puppetlabs/code/environments/production/hieradata/common.yaml"
---
version: 5

classifier::classes:
  - sensu
  - sysadmins
“我的查找”命令提供以下值:

#  puppet lookup --environmentpath environments classifier::classes                                        ---
- nagios
- "--sensu"
- webserver
调试命令输出:

# puppet lookup --environmentpath environments --explain classifier::classes
Searching for "lookup_options"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "Other YAML hierarchy levels"
      Merge strategy hash
        Path "/etc/puppetlabs/code/environments/production/hieradata/groups/webserver.yaml"
          Original path: "groups/%{facts.hostname}.yaml"
          No such key: "lookup_options"
        Path "/etc/puppetlabs/code/environments/production/hieradata/os/RedHat.yaml"
          Original path: "os/%{facts.os.family}.yaml"
          Path not found
        Path "/etc/puppetlabs/code/environments/production/hieradata/common.yaml"
          Original path: "common.yaml"
          No such key: "lookup_options"
  Module "classifier" not found
Searching for "classifier::classes"
  Global Data Provider (hiera configuration version 5)
    Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
    Hierarchy entry "Other YAML hierarchy levels"
      Path "/etc/puppetlabs/code/environments/production/hieradata/groups/webserver.yaml"
        Original path: "groups/%{facts.hostname}.yaml"
        Found key: "classifier::classes" value: [
          "nagios",
          "--sensu",
          "webserver"
        ]
  • 为什么我得到不同的输出
  • 为什么我的调试命令没有给出“合并策略”消息
  • 谢谢 SR


    根据Matt的回复,我已经在common.yaml文件中添加了这个

    # puppet lookup --environmentpath environments classifier::classes
    ---
    - sysadmins
    - nagios
    - webserver
    

    RIPieenar所做的与您所做的(查找/数据提供程序版本、模块数据与环境数据等)之间存在一些差异,但导致输出差异的主要原因是在合并策略中没有使用“deep_merge”。在您的puppetserver上安装
    deep\u merge
    gem后,您可以将查找更改为使用该策略,而不是
    hash

    # /etc/puppetlabs/code/environments/production/hieradata/common.yaml
    lookup_options:
      classifier::classes:
        merge:
          strategy: deep
          knockout_prefix: "--"
          unpack_arrays: ","
          sort_merge_arrays: true
    

    这将为您提供与他在其博客中发布的内容相同的输出。

    谢谢您提供的信息。解包数组选项给了我错误。删除该选项后,该选项起作用。给了我以下消息:错误:无法运行:合并选项的类型错误,无法识别的键“unpack\u arrays”