测试解析与puppetmaster端口是否畅通
telnet server.puppet.com 8140如果不通,可以把server.puppet.com换成服务端的IP地址试试Connection closed by foreign host出现上面的提示,说明是通的在客户端执行命令:puppetd --test --server server.puppet.com# puppetd --test --server server.viong.com命令是指puppetd 从 server.viong.com去读取puppet配置文件. 第一次连接,双方会进行ssl证书的验证,这是一个新的客户端,在服务器端那里还没有被认证,因此需要在服务器端进行证书认证以下这步批准证书是在服务端操作查看当前待批准证书列表[root@server ~]# puppetca –lserver.log.com (B0:85:72:E6:7D:63:EA:CC:BD:0C:E4:F1:70:89:24:70)批准当前证书[root@server ~]# puppetca -s server.log.comnotice: Signed certificate request for server.log.comnotice: Removing file Puppet::SSL::CertificateRequest server.log.com at'/var/lib/puppet/ssl/ca/requests/client1.viong.com.pem'查看验证签名,注意前面的+号,说明已经签名[root@server ~]# puppetca -a --list+ server.viong.com (43:33:D3:A0:26:C4:E9:89:66:A6:DC:54:20:90:E9:4D) (alt names:DNS:puppet, DNS:puppet.viong.com, DNS:server.viong.com)--------------------------------------------------------------------------------------------------如果要批准全部证书puppetca -s -a也可以在puppetmaster端的puppet.conf加入这行:autosign = true服务端就自动签证书回到客户端操作,从服务端取回已批准的证书[root@client1 puppet-2.7.14]# puppetd --test --server server.viong.comwarning: peer certificate won't be verified in this SSL sessioninfo: Caching certificate for client1.viong.cominfo: Caching certificate_revocation_list for cainfo: Caching catalog for client1.viong.cominfo: Applying configuration version '1338897814'info: Creating state file /var/lib/puppet/state/state.yamlnotice: Finished catalog run in 0.02 seconds验证证书是否正确服务端:[root@server ~]# md5sum /var/lib/puppet/ssl/ca/signed/client1.viong.com.pem8529a6f2d42c1b492c016fe870b744b6 /var/lib/puppet/ssl/ca/signed/client1.viong.com.pem客户端:[root@client1 puppet-2.7.14]# md5sum /var/lib/puppet/ssl/certs/client1.viong.com.pem8529a6f2d42c1b492c016fe870b744b6 /var/lib/puppet/ssl/certs/client1.viong.com.pem------------------------------------------------------------------------------------------------出现修改主机名问题引起无法认证,需要重新申请证书,操作以下两个步骤:服务端:[root@server ca]# rm -rf /var/lib/puppet/ssl/ca/signed/client1.viong.com.pem客户端:[root@client1 puppet-2.7.14]# rm -rf /var/lib/puppet/ssl/ ------------------------------------------------------------------------------------------------功能测试服务端:建立pp文件测试puppet的第一个执行的代码是在/etc/puppet/manifest/site.pp因此这个文件必须存在,而且其他的代码也要通过代码来调用.[root@server ~]# vim /etc/puppet/manifests/site.ppnode default { file {"/tmp/viong.txt":content=>"good,test pass!\n";}上面的代码对默认连入的puppet客户端执行一个操作,在/tmp目录生成一个viong.txt文件,内容是good,test pass! 并自动回车换行初次创建pp文件,需要重启puppetmaster[root@server ~]# service puppetmaster restart 停止 puppetmaster: [确定]启动 puppetmaster: [确定]客户端:[root@client1 puppet-2.7.14]# puppetd --test --server server.puppet.cominfo: Caching catalog for client1.viong.cominfo: Applying configuration version '1338897814'notice: /Stage[main]//Node[default]/File[/tmp/viong.txt]/ensure: defined content as '{md5}9a3f5438e1d35a72d853974203de4254'notice: Finished catalog run in 0.03 seconds成功的话就会显示puppet反馈一些调试信息,并在/tmp目录下创建了 /tmp/viong.txt文件.[root@client1 puppet-2.7.14]# cat /tmp/viong.txtgood,test pass!==============================================================设置客户端的守护进程[root@client1 puppet-2.7.14]# puppetd --test --server server.puppet.scom --verbose --waitforcert 100info: Caching catalog for client1.viong.cominfo: Applying configuration version '1338897814'notice: Finished catalog run in 0.03 seconds--server 服务端FQDN –-verbose 输出冗余信息 –-waitforcert 超时100