手机版
你好,游客 登录 注册
背景:
阅读新闻

Puppet的安装部署实例

[日期:2015-03-26] 来源:Linux社区  作者:liangey [字体: ]

关于puppet的说明这里就不详细介绍了,下面我们直接开始puppet的部署安装吧!

特别说明:请注意客户端和服务器端版本要一致。如果版本不一致的话,那么高版本的只能是puppet server,另一台只能作为puppet客户端,也就是说puppet 服务端的版本可以大于或者等于客户端版本。

1.关闭防火墙
[root@puppet01~]service iptables stop
[root@puppet01~]chkconfig iptables off

2.设置selinux
[root@puppet01~]sed -i's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

3.修改服务端跟客户端hosts文件,添加IP和主机名称
[root@puppet01~]# cat /etc/hosts
127.0.0.1  localhost localhost.localdomain localhost4localhost4.localdomain4
::1        localhost localhost.localdomainlocalhost6 localhost6.localdomain6
192.168.1.231 puppetserver 
192.168.1.232 puppetclient

4.服务端安装puppetmaster
rpm-Uvh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-1.noarch.rpm
yum install puppet-server –y

5.客户端安装puppet
rpm-Uvh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-1.noarch.rpm
yum install puppet -y

6.服务端开启puppetmaster服务
/etc/init.d/puppetmasterstart

7.客户端证书申请
puppetagent --server puppetserver --test

8.服务端查看证书是否生成
[root@puppet01~]# puppet cert --list
  "puppet02" (SHA256)36:1F:C6:80:48:66:90:52:87:3B:55:AB:6C:66:31:3F:33:35:CF:AE:8A:3A:BA:F9:D0:70:EE:C2:3F:FD:23:9C

9.服务端颁发证书
1.可以为特定的主机颁发证书命令:puppetcert –s 
2.给所有的主机颁发证书命令:puppetcert –s and –a 
为客户端颁发证书:
puppetcert --s puppetclient #后面是主机名

10.客户端/tmp下面创建个test.txt文件,做测试
touchtest.txt
#服务端下面编辑site.pp
vi /etc/puppet/manifests/site.pp 
node default { 
file { 
"/tmp/test.txt": content => "helo,test!"; 
  } 
}

11.客户端测试
puppetagent --server puppetserver --test
  成功信息:
  Info:Caching certificate for puppetclient
Info:Caching certificate_revocation_list for ca
Info:Caching certificate for puppetclient
Info:Retrieving pluginfacts
Info:Retrieving plugin
Info:Caching catalog for puppetclient
Info:Applying configuration version '1426557149'
Notice:/Stage[main]/Main/Node[default]/File[/tmp/test.txt]/content: 
---/tmp/test.txt    2015-03-1621:51:08.889040996 -0400
+++/tmp/puppet-file20150316-1468-1n3cxlt-0 2015-03-1621:52:29.746041636 -0400
@@-0,0 +1 @@
+hello,test!
\No newline at end of file
 
Info:Computing checksum on file /tmp/test.txt
Info:/Stage[main]/Main/Node[default]/File[/tmp/test.txt]: Filebucketed /tmp/test.txtto puppet with sum d41d8cd98f00b204e9800998ecf8427e
Notice:/Stage[main]/Main/Node[default]/File[/tmp/test.txt]/content: content changed'{md5}d41d8cd98f00b204e9800998ecf8427e' to'{md5}18ea2a60db7763506261f87ecb82fb96'
Info:Creating state file /var/lib/puppet/state/state.yaml
Notice:Finished catalog run in 0.05 seconds

12.设置puppet自动认证
在服务端的puppet.conf配置文件里面[main]下方加入
autosign= true
然后重启puppetmaster服务。
#这样在客户端执行puppetd –server=puppetserver --test服务端会自动认证

13.重新生成证书:
因为很多时候需要更换主机名称,所以需要重新认证
1.首先在客户端删除:rm –rf /var/lib/puppet/ssl文件夹
2.然后在服务端删除:puppet cert--clean puppetclient
3.最后重新获取证书:puppet agent--server puppetserver --test

14.客户端配置puppet相关参数和同步时间:
vi /etc/puppet/sysconfig/puppet
#The puppetmaster server
PUPPET_SERVER=puppetserver
#If you wish to specify the port to connect to do so here
PUPPET_PORT=8140
#Where to log to. Specify syslog to send log messages to the system log.
PUPPET_LOG=/var/log/puppet/puppet.log
#You may specify other parameters to the puppet client here
PUPPET_EXTRA_OPTS=--waitforcert=500
#最后重启puppet 服务
/etc/init.d/puppetstart
#默认配置完毕后,客户端是半小时同步一次的,我们可以修改同步的时间间隔:
vim/etc/puppet/puppet.conf
#在[agent]下方加入:runinterval = 60 
#代表是60秒跟服务器同步一次
#最后重启puppet服务
/etc/init.d/puppetstart

15.puppetrun的使用(puppet kick)
#在服务器端使用puppetrun这个命令可以给客户端发送一段信号,告诉客户端立刻跟服务器同步
1.    修改客户端上的puppet配置文件
vim /etc/puppet/puppet.conf
在[agent]下方添加
listen = true #目的是让puppet监听8139端口
2.    修改客户端的puppet的/etc/sysconfig/puppet文件
vim /etc/sysconfig/puppet
PUPPET_SERVER=puppetserver  #server主机名称
3.    在客户端新建namespaceauth.conf文件
[puppetrunner]
allow *
4.    在客户端修改auth.conf,在 paht / 的前面添加以下内容:
#test
path /run
method save
allow *
5.    最后重启puppet服务
/etc/init.d/puppet restart
6.    在服务端测试命令:
puppet kick –d host puppetclient
#code 0表示成功

16.文件同步
1.首先编辑fileserver.conf文件:
[root@masterpuppet]# vim fileserver.conf
[files]    定义模块名称è后面的site.pp里面要调用这个名称
path/opt/
allow192.168.1.0/24
 
2.然后编辑site.pp文件:
[root@masterpuppet]# vim manifests/site.pp
file{"/opt":  # 传输的文件名称这个可以随便写
source=>"puppet:///files/", #要传输的文件
recurse=> true;  # 传送该目录下所有文件
}
#puppet://"等价于主配置文件puppet.config中的modulepath值
 
3.最后执行命令
puppet agent --server puppetserver --test

 

Puppet 学习系列:

Puppet 学习一:安装及简单实例应用 http://www.linuxidc.com/Linux/2013-08/88710.htm

Puppet学习二:简单模块配置和应用 http://www.linuxidc.com/Linux/2013-08/88711.htm

相关阅读:

有关Puppet agent端三种备份恢复方案探讨研究 http://www.linuxidc.com/Linux/2013-07/87885.htm
选择更安全的方式注册你的Puppet节点 http://www.linuxidc.com/Linux/2013-07/87884.htm
通过配置SSH深刻理解Puppet的语法及工作机制 http://www.linuxidc.com/Linux/2013-07/87882.htm
Puppet利用Nginx多端口实现负载均衡 http://www.linuxidc.com/Linux/2013-02/79794.htm
CentOS(5和6)下Puppet的C/S模式实例 http://www.linuxidc.com/Linux/2011-12/50502.htm

Puppet 的详细介绍请点这里
Puppet 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-03/115506.htm

linux
相关资讯       Puppet  Puppet安装 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款