hiera CLI查找失败,但木偶代理-t工作

时间:2014-09-22 18:11:45

标签: puppet

[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] #cat environment / 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,我得到了相同的结果。

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

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

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