1、操作系统:CentOS 5.3 (64位系统)
2、系统架构:
192.168.9.29 服务器
192.168.9.16 客户端
3、安装ruby.(安装puppet先决条件服务端和客户端都要安装)
#yum -y install ruby ruby-devel ruby-doc*
4、服务端安装
(1)安装Facter 用来获取客户端系统信息
#cd /usr/local/src
#wget http://puppetlabs.com/downloads/facter/facter-latest.tgz下载最新稳定版facter
#tar -xvzf facter-latest.tgz
#cd facter-latest
#ruby install.rb 安装
#cd ../
(2)安装puppet
#wget http://puppetlabs.com/downloads/puppet/puppet-latest.tgz 下载最新稳定版puppet。
#cd puppet-*
#ruby install.rb安装
#mkdir /etc/puppet
#cp conf/auth.conf /etc/puppet/
#cp conf/namespaceauth.conf /etc/puppet/
#cp conf/redhat/puppet.conf /etc/puppet/
#cp conf/redhat/server.init /etc/init.d/puppetmaster
#chmod +x /etc/init.d/puppetmaster
5、客户端安装
和服务端安装方法一样。
#mkdir /etc/puppet
#cp conf/auth.conf /etc/puppet/
#cp conf/namespaceauth.conf /etc/puppet/
#cp conf/redhat/puppet.conf /etc/puppet/
#cp conf/redhat/client.init /etc/init.d/puppet
#chmod +x /etc/init.d/puppet
6、服务端配置
(1)、修改/etc/vhosts
#vim /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.9.29 master.test.com
192.168.9.16 client.test.com
(2)、修改hostname
#vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=master.test.com
(3)、hostname master.test.com
7、客户端配置192.168.9.16
(1)、修改/etc/vhosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.9.29 master.test.com
192.168.9.16 client.test.com
(2)、修改hostname
#vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=client.test.com
#/etc/init.d/network restart
8、启动服务端服务
service puppetmaster start (服务器端)
service puppet start (客户端)
如果要是以上服务无法起来那就是你没有建立puppet组跟账户
groupadd puppet
useradd -g puppet puppet
9、客户端请求服务端认证
在客户端执行
#puppetd --server master.test.com --test
在这时候或许会报错其中很大的原因就是服务器跟客户端上的时间不同步造成的解决方法:NTP
/usr/sbin/ntpdate 192.168.9.29
在服务端执行
#puppetca -l 查看客端请求
client.test.com (B0:85:72:E6:7D:63:EA:CC:BD:0C:E4:F1:70:89:24:70)
#puppetca -s client.test.com 签发证书
notice: Signed certificate request for client.test.com
notice: Removing file Puppet::SSL::CertificateRequest client.test.com at
'/var/lib/puppet/ssl/ca/requests/client.test.com.pem'
如果是多台客户端的话可以用puppetca -s -a 全部签发
10、测试
在服务器端建立site.pp
#vi/etc/puppet/manifests/site.pp
node default{
file{"/tmp/temp1.txt":content => "hello,first puppet manifest";}
}
在客户端执行命令
puppetd --server master.test.com --test
info: Caching catalog for client.test.com
info: Applying configuration version '1338897814'
notice: /Stage[main]//Node[default]/File[/tmp/temp1.txt]/ensure: defined content as '{md5} 9a3f5438e1d35a72d853974203de4254'
notice: Finished catalog run in 0.03 seconds
执行完之后如果成功的话会在客户端/tmp下生成temp1.txt
以下是我遇到的一些问题
若是修改客户端主机名的话也可以使用以下方法
err: Could not request certificate: Retrieved certificate does not match private key; please remove certificate from server and regenerate it with the current key
解决方法:按照下面a-d四个步骤,即可。
a.在客户端可以删除rm -rf /var/lib/puppet/ssl/,
b.在puppetmaster端,执行 puppetca -c 客户端主机名
c. 客户端在重新生成证书请求: puppet –test –server puppetmaster主机名
d.在puppetmaster端,执行 puppetca -s 客户端主机名