Puppet Hiera 5 查找函数值
Puppet Hiera 5 Lookup function value
我正在测试此博客 post 我系统中的最后一个示例。我的查找命令给出了不同的结果。我喜欢理解为什么
https://www.devco.net/archives/2016/03/13/the-puppet-4-lookup-function.php
对于这个查找命令,他正在获取这个值
% 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"
]
- 为什么我得到不同的输出?
- 为什么我的调试命令没有给出 'Merge strategy ' 消息?
谢谢
SR
根据 Matt 的回复,我已将其添加到我的 common.yaml 文件中。
# puppet lookup --environmentpath environments classifier::classes
---
- sysadmins
- nagios
- webserver
RIPieenar 所做的与您所做的之间存在一些差异(lookup/data 提供程序版本、模块数据与环境数据等),但造成输出差异的主要原因是缺乏在合并策略中使用 "deep_merge"。在您的 puppetserver 上安装 deep_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
这将为您提供与他在其博客中发布的内容相同的输出。
我正在测试此博客 post 我系统中的最后一个示例。我的查找命令给出了不同的结果。我喜欢理解为什么
https://www.devco.net/archives/2016/03/13/the-puppet-4-lookup-function.php
对于这个查找命令,他正在获取这个值
% 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"
]
- 为什么我得到不同的输出?
- 为什么我的调试命令没有给出 'Merge strategy ' 消息?
谢谢 SR
根据 Matt 的回复,我已将其添加到我的 common.yaml 文件中。
# puppet lookup --environmentpath environments classifier::classes
---
- sysadmins
- nagios
- webserver
RIPieenar 所做的与您所做的之间存在一些差异(lookup/data 提供程序版本、模块数据与环境数据等),但造成输出差异的主要原因是缺乏在合并策略中使用 "deep_merge"。在您的 puppetserver 上安装 deep_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
这将为您提供与他在其博客中发布的内容相同的输出。