转载:http://blog.51cto.com/ywzhou/1576330
一、查看信息
1、查看puppet版本
[root@puppet ~]# puppet --version
3.7.1
2、查看模块位置
[root@puppet ~]# puppet config print modulepath
/etc/puppet/modules:/usr/share/puppet/modules
3、查看报告
[root@puppet ~]# puppet agent -t --summarize
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for puppet.ewin.com
Info: Applying configuration version '1415922617'
Notice: Finished catalog run in 0.07 seconds
Changes:
Events:
Resources:
Total: 8
Time:
Filebucket: 0.00
File: 0.00
Schedule: 0.00
Config retrieval: 0.41
Total: 0.41
Last run: 1415929219
Version:
Config: 1415922617
Puppet: 3.7.1
4、查看客户端更新间隔
[root@puppet ~]# puppet agent --configprint runinterval
1800
默认1800秒,即半小时,更新间隔可修改puppet.conf
runinterval = 120
5、查看请求证书
[root@puppet ~]# ls /var/lib/puppet/ssl/ca/requests/
6、查看已签证书
[root@puppet ~]# ls /var/lib/puppet/ssl/ca/signed/
centostest.ewin.com.pem ywzhou-pc.ewin.com.pem
puppet.ewin.com.pem zabbix.ewin.com.pem
7、服务端查看证书
[root@puppet ~]# puppet cert list --all
+ "puppet.ewin.com" (SHA256) 72:FD:30:87:86:CD:3E:CB:F4:6D:2A:C9:22:95:15:9B:48:C6:82:94:76:47:E0:08:57:A9:89:35:40:64:CB:F2 (alt names: "DNS:puppet", "DNS:puppet.ewin.com")
+ "ywzhou-pc.ewin.com" (SHA256) 29:33:6F:64:7D:98:87:FA:FB:B4:4C:E1:0B:BE:89:AB:F0:3A:3A:DA:29:11:C8:87:83:6C:4E:87:91:0E:F8:9E
+ "zabbix.ewin.com" (SHA256) 6F:1E:2B:46:2D:31:95:A2:71:59:A3:73:C4:A7:53:4B:29:91:72:65:4A:0D:32:A7:F1:6A:86:B6:D1:4A:FF:2D
二、验证测试
1、服务端编写代码
[root@puppet ~]# vi /etc/puppet/manifests/site.pp
node default {
case $operatingsystem {
Windows: {
$file_path = 'C:\\helloworld.txt'
}
/(RedHat|CentOS|Fedora|Ubuntu|Debian)/: {
$file_path = '/tmp/helloworld.txt'
}
}
file { $file_path : content => "hello, world";}
}
说明:设置默认节点配置,完成安装一、二后,通过参数$operatingsystem自动判断客户端系统,生成相应的helloworld.txt测试文件,并通过content定义内容。
2、客户端测试
[root@puppet ~]# puppet agent --server puppet.ewin.com --test
结论:可以看到两个客户端分别生成了文件,内容也是puppet定义好的;
将文件删除,到达下一个同步时间,文件又会自动生成,测试安装成功。
3、问题及解决
(1)插件同步问题
客户端运行puppet agent -test时报错:
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve information from environment production source(s) puppet://puppet.ewin.com/plugins
这是因为没有安装插件,解决方法是设置客户端和服务端的/etc/puppet.conf中的pluginsync=true 改成pluginsync=false,并重启puppetmaster或者建个插件让其同步工作起来。
(2)是否允许虚拟化问题
[root@puppet ~]# vi /etc/puppet/manifests/site.pp
Package { allow_virtual => true, }