一旦我安装了Puppet,Foreman,Hiera和Facter,我怎样才能让他们一起工作呢?
Foreman GUI工作正常,可以使用浏览器进行查看。 Hiera是安装的,通过我在互联网上阅读的指南,它似乎configuration正确,Facter也可以正常工作,但代理没有从Puppet服务器获取模块。
我添加了一个非常简单的MOTD模块,并将其configuration为在common.yaml运行。 但是模块没有安装在代理机器上,也没有显示错误。
在服务器和客户端上运行puppet agent -t工作:
[root@puppet production]# puppet agent -t Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Info: Caching catalog for puppet.nj.peer39.com Info: Applying configuration version '1425802774' Notice: Finished catalog run in 0.05 seconds [root@puppet production]#
hiera.yaml看起来像这样:
[root@puppet production]# cat /etc/puppet/hiera.yaml :backends: - yaml :yaml: :datadir: '/etc/puppet/hieradata/%{::environment}' :hierarchy: - fqdns/%{::fqdn} - roles/%{::role} - domains/%{::domain} - common
environment.conf看起来像这样:
[root@puppet production]# pwd /etc/puppet/environments/production [root@puppet production]# cat environment.conf modulepath = modules manifest = /etc/puppet/environments/production/manifests/ [root@puppet production]#
我也尝试通过fqdn.yaml文件加载模块,但无济于事,并没有显示错误。
/etc/puppet/puppet.conf看起来像这样:
[master] autosign = $confdir/autosign.conf { mode = 664 } reports = foreman external_nodes = /etc/puppet/node.rb node_terminus = exec ca = true ssldir = /var/lib/puppet/ssl certname = puppet.company.com strict_variables = false environmentpath = $confdir/environments
编辑#1:
我的common.yaml看起来像这样:
classes: - motd
当我说fqdn.yaml我的意思是:
[root@puppet fqdns]# pwd /etc/puppet/hieradata/production/fqdns [root@puppet fqdns]# ll total 8 -rw-r--r-- 1 root root 23 Mar 11 09:26 pnd01.company.yaml -rw-r--r-- 1 root root 17 Mar 12 08:24 puppet.company.com.yaml [root@puppet fqdns]#
这是我的site.pp ,位于/etc/puppet/environments/production/manifests :
[root@puppet manifests]# cat site.pp hiera_include("classes", []) Package { allow_virtual => false, } node default { }
hiera.yaml已被更改,则需要重新启动hiera.yaml --- common.yaml
--- classes: - motd
代替
classes: - motd
/etc/puppet/hiera.yaml
:yaml: :datadir: "/etc/puppet/environments/%{::environment}/hieradata"
每个环境应该包含一个hieradata目录,它应该包含common.yaml。 如果没有使用环境,hiera.yaml如下所示:
:yaml: :datadir: "/etc/puppet/hieradata"
把common.yaml移到这个目录并重新启动puppetmaster
site.pp而不是hiera_include("classes", [])定义hiera_include('classes') hiera_include("classes", [])就足够了