创建puppet用户组:
# sudo puppet resource group puppet ensure=present
创建puppet用户:
# sudo puppet resource user puppet ensure=present gid=puppet shell='/sbin/nologin'
# cp -af ext/redhat/puppet.conf /etc/puppet/
服务端在[main]中增加:
server = puppetmaster的hostname
certname = puppetmaster的hostname
客户端在[main]中增加:
server = puppetmaster的hostname
创建puppetmaster启动脚本:
# cp -af puppet-3.3.1/ext/redhat/server.init /etc/init.d/puppetmaster
# chmod +x /etc/init.d/puppetmaster
可以使用puppet启动并永久启用puppetmaster:
# puppet resource service puppetmaster ensure=running enable=true
或:
# service puppetmaster start/stop
创建puppet启动脚本:
# cp -af ext/redhat/client.init /etc/init.d/puppet
# chmod +x /etc/init.d/puppet
可以使用puppet启动并永久启用puppet:
# puppet resource service puppet ensure=running enable=true
或:
# service puppet start/stop
7、注册操作
客户端创建注册请求:
puppet agent -t同puppet agent --test
[root@master ~]# puppet agent --test
Info: Caching certificate for ca
Info: Creating a new SSL certificate request for salve.puppet.com
Info: Certificate Request fingerprint (SHA256): 8C:66:ED:74:BC:A4:8A:94:F4:8A:9D:CE:B6:04:2A:8B:61:13:BE:D7:F7:71:19:7D:11:DA:49:AC:E5:C1:7A:13
Exiting; no certificate found and waitforcert is disabled
服务端查看注册请求:
[root@master ~]# puppet cert list
"salve.puppet.com" (SHA256) 8C:66:ED:74:BC:A4:8A:94:F4:8A:9D:CE:B6:04:2A:8B:61:13:BE:D7:F7:71:19:7D:11:DA:49:AC:E5:C1:7A:13
# puppet cert list --all
查看所有客户端的请求(有+号的代表已经签好证书可以通信,没有加号的代表尚未签好证书)
服务端受理注册请求:
[root@master ~]# puppet cert sign salve.puppet.com
Notice: Signed certificate request for puppetclient1.com
Notice: Removing file Puppet::SSL::CertificateRequest puppetclient1.com at '/var/puppet/vardir/ssl/ca/requests/puppetclient1.com.pem'
# puppet cert sign --all
受理所有注册请求
客户端确认注册是否成功:
[root@master ~]# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for puppetclient1.com
Info: Applying configuration version '1382687178'
Notice: Finished catalog run in 0.03 seconds
至此,客户端已经在服务端注册成功;
服务端清理证书:
[root@master ~]# puppet cert clean salve.puppet.com
8、配置服务端自动受理注册
在服务端:
/etc/puppet/puppet.conf
master中增加:autosign = ture
[master]
autosign = true
/etc/puppet/autosign.conf
配置客户端的certname,(可直接使用hostname),一个一行,例:
# cat /etc/puppet/autosign.conf
salve.puppet.com
9、测试是否正常
在服务端编写执行代码:
[root@master ~]# vim /etc/puppet/manifests/site.pp
-----------------添加如下内容-----------------------
file { "/tmp/temp1.txt":
content => "Hello World\n"; }
-----------------添加内容结束------------------------
在客户端执行命令:
[root@salve~]# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for salve.puppet.com
Info: Applying configuration version '1382687704'
Notice: /Stage[main]//File[/tmp/temp1.txt]/ensure: defined content as '{md5}e59ff97941044f85df5297e1c302d260'
Notice: Finished catalog run in 0.03 seconds
在客户端查看是否成功创建:
[root@salve~]# cat /tmp/temp1.txt
Hello World
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/27039319/viewspace-1762909/ ,如需转载,请注明出处,否则将追究法律责任。