2014-09-22 62 views
1

[根@傀儡木偶]#貓/etc/hiera.yamlhiera CLI查找失敗但木偶劑-t工作

--- 
:backends: 
    - yaml 
:yaml: 
    :datadir: '/etc/puppet/hieradata' 
:hierarchy: 
    - env/%{::environment}/fqdn/%{::fqdn} 
    - hostgroup/%{::hostgroup1} 
    - global 

[根@傀儡木偶]#貓hieradata/env的的/ dev/FQDN/client00.itw.local.yaml

fruit::a: 
    - 'DevFQDN-kiwi' 

[根@傀儡木偶]#貓環境的/ dev /模塊/果/艙單/ 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}", 
     } 
} 

水果::一個似乎可熔酚醛樹脂VE對client00.itw.local

[[email protected] ~]# 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不會對木偶大師

[[email protected] 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水果::一個-m client00.itw .local,我得到了同樣的結果。

感謝您的幫助。

+0

你確定你的hiera.yaml在/ etc下嗎?因爲通常木偶代理使用/etc/puppet/hiera.yaml而cli使用/etc/hiera.yaml https://docs.puppetlabs.com/hiera/1/configuring.html – Emyl 2014-09-23 16:02:23

+0

是的。我連接兩個文件。 – user1141993 2014-09-23 17:08:40

回答

1

環境是木偶特定實際上,包含在木偶庫

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

+0

謝謝。「hiera -d fruit :: a :: environment = dev :: fqdn = client00.itw.local」返回了正確的值。 – user1141993 2014-09-23 17:09:22

+0

後續問題:「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可以節省我一些打字。 – user1141993 2014-09-23 17:12:45