Puppet 代理无法找到测试模块

Puppet 代理无法找到测试模块

我正在设置 Puppet Master 和 Agent。它们在同一台主机上运行,​​因为我也想让 Puppet 管理这台主机。Agent 无法找到软件包提供的便捷测试模块。

我正在运行 ubuntu trusty (14.04 LTS) 并安装了 puppetmaster-passenger 和 puppet 软件包以开始使用。到目前为止一切顺利。

root@mangosteen:/etc/puppet# dpkg -l | grep puppet
ii  puppet                           3.4.3-1ubuntu1.1    [...]
ii  puppet-common                    3.4.3-1ubuntu1.1    [...]
ii  puppetmaster                     3.4.3-1ubuntu1.1    [...]
ii  puppetmaster-common              3.4.3-1ubuntu1.1    [...]
ii  puppetmaster-passenger           3.4.3-1ubuntu1.1    [...]
root@mangosteen:/etc/puppet# 

我的/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
templatedir=$confdir/templates
prerun_command=/etc/puppet/etckeeper-commit-pre
postrun_command=/etc/puppet/etckeeper-commit-post

[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

dns_alt_names = mangosteen.example.com,puppetmaster.example.com

该软件包提供了一个快速测试,我认为这意味着启动代理将导致将 HelloWorld 写入 /tmp/hello:

root@mangosteen:/etc/puppet# pwd
/etc/puppet
root@mangosteen:/etc/puppet# find manifests/ -type f
manifests/site.pp
root@mangosteen:/etc/puppet# find modules/ -type f
modules/test/manifests/init.pp
root@mangosteen:/etc/puppet# cat manifests/site.pp
include test
root@mangosteen:/etc/puppet# cat modules/test/manifests/init.pp
class test { file { \/tmp/hello\: content => \HelloWorld\ } }
root@mangosteen:/etc/puppet# 

但事实并非如此。(回想一下,代理和主控位于同一主机上,该主机名为 mangosteen.example.com,别名为 puppetmaster.example.com)

root@mangosteen:/etc/puppet# puppet agent --test
Info: Retrieving plugin
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class test for mangosteen.example.com on node mangosteen.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
root@mangosteen:/etc/puppet# 

通过该操作,服务器日志(/var/log/puppet/masterhttp.log)相当普通:

[2015-10-02 12:54:08] 139.162.x.y - - [02/Oct/2015:12:54:08 UTC] "GET /production/node/mangosteen.example.com? HTTP/1.1" 200 4487
[2015-10-02 12:54:08] - -> /production/node/mangosteen.example.com?
[2015-10-02 12:54:08] 139.162.x.y - - [02/Oct/2015:12:54:08 UTC] "GET /production/file_metadatas/plugins?links=manage&recurse=true&ignore=.svn&ignore=CVS&ignore=.git&checksum_type=md5 HTTP/1.1" 200 278
[2015-10-02 12:54:08] - -> /production/file_metadatas/plugins?links=manage&recurse=true&ignore=.svn&ignore=CVS&ignore=.git&checksum_type=md5
[2015-10-02 12:54:09] 139.162.x.y - - [02/Oct/2015:12:54:09 UTC] "POST /production/catalog/mangosteen.example.com HTTP/1.1" 400 89
[2015-10-02 12:54:09] - -> /production/catalog/mangosteen.example.com
[2015-10-02 12:54:09] 139.162.x.y - - [02/Oct/2015:12:54:09 UTC] "PUT /production/report/mangosteen.example.com HTTP/1.1" 200 9
[2015-10-02 12:54:09] - -> /production/report/mangosteen.example.com

在我看来,代理的调试输出毫无趣味,主要是查找其证书。这些命令合理地总结了这种无聊:

root@mangosteen:/etc/puppet# puppet agent --test --debug --trace 2>&1 | grep -i module
root@mangosteen:/etc/puppet# puppet agent --test --debug --trace 2>&1 | grep -i test
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class test for mangosteen.example.com on node mangosteen.example.com
root@mangosteen:/etc/puppet# 

有什么指出我做错了什么吗?

答案1

如果你在拥有 Puppet Master 的同一主机中使用 Puppet Agent,则可以按照@FelixFrank建议 使用 Puppet Apply

无论如何,问题是,你没有定义节点"mangosteen.example.com",你也可以解决这个问题,定义default node,Puppet 寻找节点定义,如果没有找到,则使用default node.

答案2

@FelixFrank 提供了答案的主要线索,即文件modules/test/manifests/init.pp有拼写错误。奇怪的是,木偶大师没有在日志中报告这一点,木偶代理只是说找不到测试类。(据我所知,找不到它是因为它没有解析。)

我对 Puppet 还很陌生,可能不知怎么搞砸了日志记录。无论如何,因为根本没有节点指令,所以这个主机没有节点指令不是问题。事实上,这是一个相当聪明的测试,因为一旦代理工作(一旦我修复了拼写错误),代理就会在 创建一个文件/tmp/hello

相关内容