【发布时间】:2014-09-22 18:11:45
【问题描述】:
[root@puppet puppet]# cat /etc/hiera.yaml
---
:backends:
- yaml
:yaml:
:datadir: '/etc/puppet/hieradata'
:hierarchy:
- env/%{::environment}/fqdn/%{::fqdn}
- hostgroup/%{::hostgroup1}
- global
[root@puppet puppet]# cat hieradata/env/dev/fqdn/client00.itw.local.yaml
fruit::a:
- 'DevFQDN-kiwi'
[root@puppet puppet]#猫环境/dev/modules/fruit/manifests/init.pp
class fruit(
$a = hiera('fruit::a' ),
$b = hiera('fruit::b'),
$c = hiera('fruit::c')
) {
notify { 'foo':
message => "a is: ${a}, b is: ${b}, c is : ${c}",
}
}
fruit::a 似乎在 client00.itw.local 上解决得很好
[root@client00 ~]# puppet agent -t
Warning: Local environment: "production" doesn't match server specified node environment "dev", switching agent to "dev".
Info: Retrieving plugin
Info: Caching catalog for client00.itw.local
Info: Applying configuration version '1411407772'
Notice: a is: DevFQDN-kiwi, b is: HostgroupAll-orange, c is : global-lime-C
但是 CLI hiera 没有在 puppet master 上返回正确的值
[root@puppet puppet]# hiera -d fruit::a ::fqdn=client00.itw.local ::hostgroup1=all
DEBUG: Mon Sep 22 13:57:16 -0400 2014: Hiera YAML backend starting
DEBUG: Mon Sep 22 13:57:16 -0400 2014: Looking up fruit::a in YAML backend
DEBUG: Mon Sep 22 13:57:16 -0400 2014: Looking for data source hostgroup/all
DEBUG: Mon Sep 22 13:57:16 -0400 2014: Looking for data source global
DEBUG: Mon Sep 22 13:57:16 -0400 2014: Found fruit::a in global
["global-lime-A"]
使用 mcollective,hiera -d fruit::a -m client00.itw.local,我得到了相同的结果。
感谢您的帮助。
【问题讨论】:
-
你确定你的 hiera.yaml 在 /etc 下吗?因为通常 puppet 代理使用 /etc/puppet/hiera.yaml 而 cli 使用 /etc/hiera.yaml docs.puppetlabs.com/hiera/1/configuring.html
-
是的。我符号链接了两个文件。
标签: puppet