puppet与其他手工操作工具有一个***的区别就是 puppet的配置具有稳定性,因此你可以多次执行puppet, 一旦你更新了你的配置文件,puppet就会根据配置文件来更改你的机器配置,通常每30分钟检查一次. puppet会让你的系统状态同配置文件所要求的状态保持一致. 比如你配置文件里面要求ssh服务必须开启. 假如不小心ssh服务被关闭了,那么下一次执行puppet的时候,puppet会发现这个异常,然后会开启 ssh 服务. 以使系统状态和配置文件保持一致.puppet就象一个魔术师,会让你的混乱的系统收敛到puppet配置文件所想要的状态。
可以使用puppet管理服务器的整个生命周期,从初始化到退役.不同于传统的例如sun的Jumpstart或者redhat的Kickstart, puppet可以长年让服务器保持***状态.只要一开始就正确的配置他们,然后再也不用去管他们.通常puppet用户只需要给机器安装好puppet并让他们运行,然后剩余的工作都由puppet来完成。
试验环境
硬件:两台服务器,虚拟服务器或者物理机器都行,ip地址分别是 192.168.10.133 (server)和 192.168.10.207(client) ;下文分别用server和client代替两个服务器.
软件:安装Centos 5X64(server),Ubuntu 12.04(client) 系统
网络:两台机器互相能访问
在server端配置: 1.设置主机名:
- [root@server ~]# uname -a
- Linux server.puppet.com 2.6.18-238.el5 #1 SMP Thu Jan 13 15:51:15 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
- [root@server ~]# hostname
- server.puppet.com
- [root@server ~]# cat /etc/hosts
- # Do not remove the following line, or various programs
- # that require network functionality will fail.
- 127.0.0.1 redmine localhost.localdomain localhost
- ::1 localhost6.localdomain6 localhost6
- 192.168.10.133 server.puppet.com server
2.配置server端的yum源(因为centos默认没有puppet 源,因此先配置puppet的源,下面链接失效可以参考:https://fedoraproject.org/wiki/EPEL/zh-cn.)
- [root@server ~]# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
3.开始安装puppet server
- [root@server ~]# yum -y install puppet-server facter ruby ruby-libs ruby-shadow
4.yum安装puppet成功,先启动服务,查看安装成功否
- [root@server ~]# service puppetmaster start
- Starting puppetmaster: [ OK ]
- [root@server ~]# ps -ef | grep puppet
- puppet 2937 1 0 11:47 ? 00:00:00 /usr/bin/ruby /usr/sbin/puppetmasterd
- root 2943 2751 0 11:47 pts/1 00:00:00 grep puppet
个人喜欢先用
- [root@server ~]# puppet master --verbose --no-daemonize
- notice: Starting Puppet master version 2.6.17
因为这个可以看到输出.跟后面的测试有关系,调试完毕.建议用守护进程方式启动
现在看到server启动没有问题.现在可以出安装 ubuntu client了
1.设置client的hostname
- liming@client:~$ hostname
- client.puppet.com
2.设置server hosts(添加如下)
- liming@client:~$ sudo vim /etc/hosts
- 192.168.10.133 server.puppet.com
3.设置ubuntu apt源
- liming@client:~$ sudo su -
- liming@client:~$ echo -e "deb http://apt.puppetlabs.com/ lucid main\ndeb-src http://apt.puppetlabs.com/ lucid main" >> /etc/apt/sources.list.d/puppet.list
- liming@client:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 4BD6EC30
- liming@client:~$ sudo apt-get update
4.安装puppet 客户端
sudo apt-get install puppet
5.测试
- liming@client:~$ sudo puppet agent --server=server.puppet.com --no-daemonize --verbose --onetime
- info: Creating a new SSL key for client.puppet.com
- warning: peer certificate won't be verified in this SSL session
- info: Caching certificate for ca
- warning: peer certificate won't be verified in this SSL session
- warning: peer certificate won't be verified in this SSL session
- info: Creating a new SSL certificate request for client.puppet.com
- info: Certificate Request fingerprint (md5): 54:CC:33:85:ED:4E:97:05:5F:6D:CE:D9:1F:1F:E9:BC
- warning: peer certificate won't be verified in this SSL session
- warning: peer certificate won't be verified in this SSL session
- warning: peer certificate won't be verified in this SSL session
服务器端查看等待请求证书连接的客户端
- [root@server ~]# puppet cert --list
- "client.puppet.com" (54:CC:33:85:ED:4E:97:05:5F:6D:CE:D9:1F:1F:E9:BC)
现在server和client 端都没问题.若想吧client 换成Centos Or RHEL 重复server 2.配置puppet的yum源.直接yum install puppet 即可!
出现的问题:
- liming@client:~$ puppetd --server server.puppet.com --test
- err: Could not retrieve catalog from remote server: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. This is often because the time is out of sync on the server or client
- warning: Not using cache on failed catalog
- err: Could not retrieve catalog; skipping run
- err: Could not send report: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. This is often because the time is out of sync on the server or client