Puppet

Hiera 數據類型不會在 Puppet 中載入

  • June 4, 2014

我花了幾天的時間,按照http://downloads.puppetlabs.com/docs/puppetmanual.pdf上的說明,甚至 Puppet Training Advanced Puppet 手冊。

當我對它進行測試時,結果總是以“nil”返回,我不知道為什麼。我在 SLES 11 上執行 Puppet 3.6.1 社區版和 Hiera 1.2.1。

我在 /etc/puppet/puppet.conf 的 puppet.conf 文件包括:

[main]
   # The Puppet log directory.
   # The default value is '$vardir/log'.
   logdir = /var/log/puppet

   # Where Puppet PID files are kept.
   # The default value is '$vardir/run'.
   rundir = /var/run/puppet

   # Where SSL certificates are kept.
   # The default value is '$confdir/ssl'.
   ssldir = $vardir/ssl
   certificate_revocation = false

[master]
   hiera_config=/etc/puppet/hiera.yaml
   reporturl = http://puppet2.vvmedia.com/reports/upload
   ssl_client_header = SSL_CLIENT_S_DN
   ssl_client_verify_header = SSL_CLIENT_VERIFY

#    certname = dev-puppetmaster2.vvmedia.com
#    ca_name = 'dev-puppetmaster2.vvmedia.com'
#    facts_terminus = rest
#    inventory_server = localhost
#    ca = false
[agent]
   # The file in which puppetd stores a list of the classes
   # associated with the retrieved configuratiion.  Can be loaded in
   # the separate ``puppet`` executable using the ``--loadclasses``
   # option.
   # The default value is '$confdir/classes.txt'.
   classfile = $vardir/classes.txt

   # Where puppetd caches the local configuration.  An
   # extension indicating the cache format is added automatically.

   # The default value is '$confdir/localconfig'.
   localconfig = $vardir/localconfig

我的 /etc/puppet/hiera.yaml 包括:

:backends: yaml
:yaml:
 :datadir: /etc/puppet/hieradata
:hierarchy:
 - common
 - database

我在 /etc/puppet/hieradata 中創建了一個目錄,其中包含:

/etc/puppet/hieradata/common.yaml

:nameserver:  ["dnsserverfoo1", "dnsserverfoo2"]
:smtp_server:  relay.internalfoo.com
:syslog_server:  syslogfoo.com
:logstash_shipper:  logstashfoo.com
:syslog_backup_nfs:  nfsfoo:/vol/logs
:auth_method:  ldap
:manage_root:  true

和 /etc/puppet/hieradata/database.yaml

:enable_graphital: true
:mysql_server_package: MySQL-server
:mysql_client_package: MySQL-client
:allowed_groups_login: extranet_users

有誰知道是什麼導致 Hiera 不載入請求的值?我什至嘗試過重新啟動大師。在此先感謝,科爾

我相信您在 yaml 文件中使用了錯誤的語法。

它應該如下所示:

---
enable_graphital: true
mysql_server_package: MySQL-server
mysql_client_package: MySQL-client
allowed_groups_login: extranet_users

或者更準確地說your_class::enable_graphital: true

但這取決於您如何在清單中使用 hiera。

使用hiera命令調試時,請記住:

  1. 它需要在主伺服器上執行(通常)
  2. 它查找 /etc/hiera.yaml(不是 /etc/puppet/hiera.yaml)。如果這對您來說更容易,請創建一個符號連結。
  3. 它在 /var/lib/hiera 中查找數據。您可能需要將其作為放置 hiera 數據的位置的符號連結

引用自:https://serverfault.com/questions/601544