1.服务器端

yum install ruby ruby-libs ruby-shadow

yum install puppet-server facter

vi /etc/puppet/puppet.conf

[master]

certname=服务器主机名或者IP 192.168.1.1

systemctl start puppetmaster.service

ps -ef|grep 8140

touch -R /etc/puppet/manifests/site.pp(这个测试不需要)

puppet master --verbose --no-daemonize

puppet cert --list(查看客户端的签名申请)

puppet cert --sign 192.168.1.2(给客户端签名)

puppet cert --clean 192.168.1.2(删除客户端签名)

1.2开启puppet自启动

RHEL7之前版本:chkconfig --level 3 5 on puppetmaster

RHEL7:      systemctl enable puppetmaster.service


2.客户端:

yum install ruby ruby-libs ruby-shadow

yum install puppet

vi /etc/puppet/puppet.conf

[agent]

certname=客户端主机名或者IP 192.168.1.2

server=服务器主机名或者IP 192.168.1.1

report=true

systemctl start puppet.service

puppet agent --server=puppet.nn.local --verbose --no-daemonize  --debug

(这个指令的作用是将puppet agent不用守护进程的模式启动,好处是能看到与服务器端的通信及证书签名的过程,方便debug。 默认puppet每2分钟向服务器端申请一次签名)

rm -rf /var/lib/puppet/ssl/certs/10.161.84.92.pem

(服务器端删除证书同时客户端也要删除本机器证书)


3.puppet简单测试

vi /etc/puppet/manifests/site.pp

node default{

        file {

                "/tmp/hellworld.txt": content => "hello,world";

        }

}

客户端执行:

puppet agent --test --server 192.168.1.1

cat /tmp/helloworld.txt即可


4.puppet分发文件测试

vi /etc/puppet/manifests/site.pp

node default{

        file {

                "/tmp/wc.log":

                source => "puppet:///tmp/wc.log";

        }

}

vi /etc/puppet/fileserver.conf(增加内容如下)

#wc add1

[tmp](注意这里一定要与site.pp里脚本目录一致)

path /tmp/

#allow 192.168.1.2

allow *

客户端执行:puppet agent --test --server 192.168.1.1

报错1:

Error: /Stage[main]/Main/Node[default]/File[/tmp/wc.log]: Could not evaluate: Could not retrieve file metadata for puppet:///tmp/wc.log: Error 400 on SERVER: Not authorized to call find on /file_metadata/tmp/wc.log with {:links=>"manage", :source_permissions=>"use"}

Wrapped exception:

Error 400 on SERVER: Not authorized to call find on /file_metadata/tmp/wc.log with {:links=>"manage", :source_permissions=>"use"}

解决1:修改fileserver.conf里目录与site.pp中脚本目录一致即可


参考:

http://blog.itpub.net/27181165/viewspace-776386/

http://blog.sina.com.cn/s/blog_61c07ac50101ad9f.html

http://369369.blog.51cto.com/319630/785895/