【问题标题】:hiera CLI lookup fails but puppet agent -t workshiera CLI 查找失败,但 puppet agent -t 有效
【发布时间】: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


【解决方案1】:

环境是 Puppet 特定的事实,包含在 Puppet 库中

在命令行中使用 hiera 时 you have to pass those facts.

【讨论】:

  • 谢谢。"hiera -d fruit::a ::environment=dev ::fqdn=client00.itw.local" 返回了正确的值。
  • 后续问题:“hiera -d fruit::a -m client00.itw.local ::enviornment=dev”返回错误值。 “hiera -d fruit::a -m client00.itw.local ::enviornment=dev ::fqdn=client00.itw.local”返回正确的值。但我希望 mcollective 能为我节省一些打字时间。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-06-06
  • 2016-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-29
  • 1970-01-01
相关资源
最近更新 更多