为什么我的木偶大师不使用hiera?

我有一个木偶大师(版本3.8.1)设置,我认为是正确设置的hiera.yaml文件,如下所示:

pete@ip-172-31-4-61:~$ cat /etc/puppet/hiera.yaml --- :hierarchy: - "%{::fqdn}" :backends: - yaml :yaml: :datadir: '/etc/puppet/hieradata' 

当我运行以下命令:

 sudo puppet master --verbose --debug --compile ip-10-1-3-7 

(ip-10-1-3-7是我的一个节点)我没有看到目录中的任何信息根据我的hiera数据。 更令人困惑的是我没有在debugging中看到这一行:

 Debug: hiera(): Hiera YAML backend starting 

我在其他傀儡艺术家看到的,我也有和Hiera一起工作的

更新:我编辑了我的puppet.conf文件,包括hiera_config按照下面的注释,并重新启动puppetmaster,但它仍然无法正常工作。

 pete@ip-172-31-4-61:~$ cat /etc/puppet/puppet.conf [main] logdir=/var/log/puppet vardir=/var/lib/puppet ssldir=/var/lib/puppet/ssl rundir=/var/run/puppet factpath=$vardir/lib/facter certname = master dns_alt_names = puppet hiera_config = $confdir/hiera.yaml [master] # These are needed when the puppetmaster is run by passenger # and can safely be removed if webrick is used. ssl_client_header = SSL_CLIENT_S_DN ssl_client_verify_header = SSL_CLIENT_VERIFY 

我正在运行Ubuntu 14.04,包含puppetlabs的软件包回购:

 pete@ip-172-31-4-61:~$ cat /etc/issue Ubuntu 14.04.2 LTS \n \l pete@ip-172-31-4-61:~$ dpkg -l "puppet*" Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-===========================-==================-==================-============================================================ rc puppet 3.8.1-1puppetlabs1 all Centralized configuration management - agent startup and com ii puppet-common 3.8.1-1puppetlabs1 all Centralized configuration management un puppet-el <none> <none> (no description available) un puppetdb-terminus <none> <none> (no description available) ii puppetlabs-release 1.0-11 all "Package to install Puppet Labs gpg key and apt repo" un puppetlabs-release-devel <none> <none> (no description available) rc puppetlabs-release-pc1 0.9.2-1trusty all Release packages for the Puppet Labs PC1 repository ii puppetmaster 3.8.1-1puppetlabs1 all Centralized configuration management - master startup and co ii puppetmaster-common 3.8.1-1puppetlabs1 all Puppet master common scripts 

更新: hieradata布局dir:

 pete@ip-172-31-4-61:~$ tree /etc/puppet/hieradata /etc/puppet/hieradata └── ip-10-1-3-7.yaml 

hiera节点文件的内容:

 pete@ip-172-31-4-61:~$ cat /etc/puppet/hieradata/ip-10-1-3-7.yaml --- classes: - nginx nginx::nginx_upstreams: 'app': ensure: present members: - localhost:5000 'site': ensure: present members: - site.my-app.com nginx::nginx_vhosts: 'localhost': proxy: 'http://site' proxy_read_timeout: '5' nginx::nginx_locations: app: location: '~ "^/(members|login|logout)"' vhost: localhost proxy: 'http://app' proxy_read_timeout: '20' ssl: false location_cfg_append: proxy_set_header: - 'X-Forwarded-Host $http_host' 

我有理由相信,即使在没有主机节点文件的另一个puppet主机上,也不会像hieradata节点文件那样做,我仍然得到Debug:hiera():Hiera YAML后端启动debugging行。

validation这一行是否在你的site.pp

 hiera_include('classes') 

然后尝试运行这个命令:

puppet master --compile host.domain.tld --debug 2>&1 | grep hiera

这应该给你这样的输出:

 Debug: hiera(): Hiera YAML backend starting [...] Debug: hiera(): Looking up $KEY in YAML backend Debug: hiera(): Looking for data source common Debug: hiera(): Looking for data source node/host.domain.tld Debug: hiera(): Found $KEY in node/host.domain.tld 

在没有| grep情况下运行上面的命令 | grep部分也应该给你类似的东西:

 Debug: importing '/etc/puppet/environments/production/modules/xxx/manifests/init.pp' in environment production 

certificate类正在被加载。

你分享的数据不清楚是否有任何类被分配给客户端,所以如果没有加载类,就不会有隐式的hiera查找。

这里是我的木偶大师的一个样本:

 Info: Not using expired facts for host.corp from cache; expired at 2015-07-21 19:42:37 +0200 Info: Caching facts for host.corp Info: Caching node for host.corp Debug: hiera(): Hiera YAML backend starting Debug: hiera(): Looking up classes in YAML backend Debug: hiera(): Looking for data source kernel/Linux Debug: hiera(): Found classes in kernel/Linux Debug: hiera(): Looking for data source osfamily/RedHat Debug: hiera(): Looking for data source os/CentOS Debug: hiera(): Found classes in os/CentOS Debug: hiera(): Looking for data source node/host.corp Debug: hiera(): Found classes in node/host.corp Debug: hiera(): Looking for data source common Debug: hiera(): Found classes in common Debug: hiera(): Looking for data source corp 

尝试debugginghiera本身(示例在这里查找与-cstring值):

 hiera --debug -c /etc/puppet/hiera.yaml "sample::foo" bla "::fqdn=host.corp" osfamily='RedHat' "::environment=production" DEBUG: 2015-07-22 16:49:20 +0200: Hiera YAML backend starting DEBUG: 2015-07-22 16:49:20 +0200: Looking up sample::foo in YAML backend DEBUG: 2015-07-22 16:49:20 +0200: Looking for data source node/host.corp DEBUG: 2015-07-22 16:49:20 +0200: Found sample::foo in node/host.corp bar 

此外,请检查facter -p节点提供的值是否正确。