我花了几天时间,按照http://downloads.puppetlabs.com/docs/puppetmanual.pdf甚至还有 Puppet Training 高级 Puppet 手册。
当我对它进行测试时,结果总是返回“nil”,我不知道为什么。我在 SLES 11 上运行 Puppet 3.6.1 社区版和 Hiera 1.2.1。
我的 puppet.conf 文件位于 /etc/puppet/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 无法加载请求的值吗?我甚至尝试过重新启动 Master。提前致谢,Cole
答案1
我认为您在 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。
答案2
使用命令调试时hiera
,请记住:
- 它需要在主机上运行(通常)
- 它查找 /etc/hiera.yaml(而不是 /etc/puppet/hiera.yaml)。如果这能让您更轻松,请创建一个符号链接。
- 它会在 /var/lib/hiera 中查找数据。你可能需要将其设为指向存放 hiera 数据的符号链接