设为首页 收藏本站
查看: 1525|回复: 0

[经验分享] 通过MCollective实现puppet向windows的推送

[复制链接]

尚未签到

发表于 2015-9-16 10:14:24 | 显示全部楼层 |阅读模式
  puppet在比较老的版本的时候是通过kick进行推送实现配置及时更新,由于kick的效率问题,在比较新的版本中开始采用第三方工具MCollective来实现,网上介绍如何部署MCollective文章也不少,但大都是linux平台下的部署,windows下的几乎没有,我在研究的时候也是一路坎坷,差点放弃,不过看到有一个老外自己成功部署后,有点不甘心,在坚持下终于配置成功,现在整理一下分享出来。
  如果你还一点都不了解MCollective,建议看看这篇文章,他讲的是在linux下部署MCollective,其中讲了各个工具的关系,其实流程都一样,只不过我这里讲的是windows客户端的部署。
  =========================================================================================
  以下每个用到的工具我都有写明自己部署时候的版本号,如果你部署完成后无法正常实现推送,可以重新指定安装每个工具的版本
  1、首先配置好puppet server和puppet client,这个很容易实现,就不详细说明了,我用到版本分别是
  puppet server(centos 6.2): 3.4.3
  puppet client(windows 2008 r2):    3.4.3
  2、安装一款 消息队列服务,你可以选择RabbitMQ或者ActiveMQ,我这里选择的是ActiveMQ,ActiveMQ是装在puppet server端,使用如下命令进行安装,
  当前ActiveMQ版本号为:5.8.0



yum install tanukiwrapper activemq activemq-info-provider
  安装完成后来对ActiveMQ进行配置,如下



[iyunv@puppetserver rpms]# vim /etc/activemq/activemq.xml

<simpleAuthenticationPlugin>
<users>
<!--              <authenticationUser username="${activemq.username}" password="${activemq.password}" groups="admins,everyone"/> --> #禁用
<authenticationUser username="mcollective" password="secret" groups="mcollective,admins,everyone"/>  #配置通信的账号及密码
</users>
</simpleAuthenticationPlugin>

<authorizationPlugin>  #配置权限,默认即可
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry queue=">" write="admins" read="admins" admin="admins" />
<authorizationEntry topic=">" write="admins" read="admins" admin="admins" />
<authorizationEntry topic="mcollective.>" write="mcollective" read="mcollective" admin="mcollective" />
<authorizationEntry topic="mcollective.>" write="mcollective" read="mcollective" admin="mcollective" />
<authorizationEntry topic="ActiveMQ.Advisory.>" read="everyone" write="everyone" admin="everyone"/>
</authorizationEntries>
</authorizationMap>
</map>
</authorizationPlugin>

<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
<transportConnector name="stomp+nio" uri="stomp://0.0.0.0:61613"/> #配置通信协议为stomp,监听61613端口
</transportConnectors>
  然后启动ActiveMQ



[iyunv@puppetserver rpms]# service activemq start
Starting ActiveMQ Broker...
[iyunv@puppetserver rpms]# chkconfig activemq on
[iyunv@puppetserver rpms]# netstat -nlatp | grep 61613  #查看监听端口
tcp        0      0 :::61613                    :::*                        LISTEN      33805/java
  3、现在开始配置MCollective,MCollective也分为客户端和服务器端,其客户端是装在puppetserver上,服务器端是装下puppetclient,我们先配置客户端,也就是puppetserver上的环境,命令如下,当前mcollective客户端版本是2.5.0:



[iyunv@puppetserver rpms]# yum install mcollective-common  mcollective-client
  然后配置mcollective客户端:



[iyunv@puppetserver rpms]# vim /etc/mcollective/client.cfg
main_collective = mcollective
collectives = mcollective
libdir = /usr/libexec/mcollective
logger_type = console
loglevel = warn
# Plugins
securityprovider = psk
plugin.psk = test123123  #MCollective通信共享密钥,和MCollective服务端保持一致
connector = activemq  #MCollective用到的通讯组件
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = 192.168.3.91 #本机ip
plugin.activemq.pool.1.port = 61613  #AcitveMQ中设置的端口号
plugin.activemq.pool.1.user = mcollective #AcitveMQ中设置的用户
plugin.activemq.pool.1.password = secret  #AcitveMQ中设置的密码
plugin.activemq.heartbeat_interval = 30  

# Facts
factsource = yaml
plugin.yaml = /etc/mcollective/facts.yaml
  
  接下来是个需要注意的地方,mcollective本身并没有相应的windows服务端安装包,在windows下安装mcollective是一件麻烦的事情,不过有大神做了mcollective安装程序,它集成了mcollective运行所需要的一个gem包,以及将mcollective安装成windows服务,点击这里下载安装包,我下载的是2.3.2版本,下载后在puppet client端安装,安装完成后windows服务里会有一个服务名:The Marionette Collective。
  注意安装前检查如下环境变量,安装的时候才用右键管理员运行程序包:



Path变量是否包含 D:\Puppet Labs\Puppet\sys\ruby\bin;D:\Puppet Labs\Puppet\bin
  然后配置mcollective服务端server.cfg,我的目录是D:\mcollective\etc下:



main_collective = mcollective
collectives = mcollective
libdir = d:\mcollective\plugins  #mcollective插件目录
logfile = d:\mcollective\mcollective.log  #mcollective日志
loglevel = info
daemonize = 1
# Plugins
securityprovider = psk
plugin.psk = test123123
connector = activemq
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = 192.168.3.91
plugin.activemq.pool.1.port = 61613
plugin.activemq.pool.1.user = mcollective
plugin.activemq.pool.1.password = secret
plugin.activemq.pool.1.heartbeat_interval = 30

# Facts
factsource = yaml
plugin.yaml = d:\mcollective\etc\facts.yaml
  完成后在puppetclient上启动mcollective服务,此时mcollective的服务端和客户端配置就已经成功,可以在puppetserver上测试mcollective的通讯是否正常,如下



[iyunv@puppetserver mcollective]# mco ping
waiwofei                                 time=42.00 ms
WIN-6BJIEV6N3T6                          time=80.98 ms
WIN-3JOT1GVGEOO                          time=89.42 ms

---- ping statistics ----
3 replies max: 89.42 min: 42.00 avg: 70.80
  4、为mcollective安装puppet agent插件,首先在puppet server端安装,当前版本是1.7.1



yum install mcollective-puppet-client mcollective-puppet-common
  接着要在puppet client安装,如果是linux可以通过命令向上面那样直接安装,window的话我们只能下载插件包,然后把相关文件复制到mcollective插件目录,通过下面地址下载,我最初下载的是1.7.1版本,但是在mcollective启动的时候无法正常加载puppet agent插件,后来换成1.6.1就没问题了,版本的问题困扰了我很久,几乎要放弃了,但是看到某个老外配置成功,发现帖子的时间是2013年6月份,我就索性把插件版本降到比较老,结果正常了。好了,通过下面下载



https://github.com/puppetlabs/mcollective-puppet-agent/releases
  解压后将里面的文件夹复制到mcollective的插件目录,我的插件目录[d:\mcollective\plugins],接着再次配置puppet client端mcollective的server.cfg,增加如下两行,这个插件的配置写法也卡住了我很久,说多了都是泪啊。。。。



main_collective = mcollective
collectives = mcollective
libdir = d:\mcollective\plugins  
logfile = d:\mcollective\mcollective.log  
loglevel = info
daemonize = 1
# Plugins
securityprovider = psk
plugin.psk = test123123
connector = activemq
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = 192.168.3.91
plugin.activemq.pool.1.port = 61613
plugin.activemq.pool.1.user = mcollective
plugin.activemq.pool.1.password = secret
plugin.activemq.pool.1.heartbeat_interval = 30
plugin.puppet.command = "D:\Puppet Labs\Puppet\bin\puppet.bat" agent
plugin.puppet.config = C:\ProgramData\PuppetLabs\puppet\etc\puppet.conf
# Facts
factsource = yaml
plugin.yaml = d:\mcollective\etc\facts.yaml
  
  ok,重启puppet client端mcollective服务,可以在puppet server通过下面的命令查看puppet client的插件的加载情况。



[iyunv@puppetserver mcollective]# mco inventory waiwofei
Inventory for waiwofei:
Server Statistics:
Version: 2.3.2
Start Time: Mon Apr 28 17:24:51 +0800 2014
Config File: D:\mcollective\etc\server.cfg
Collectives: mcollective
Main Collective: mcollective
Process ID: 73044
Total Messages: 4
Messages Passed Filters: 4
Messages Filtered: 0
Expired Messages: 0
Replies Sent: 3
Total Processor Time: 1.014 seconds
System Time: 0.39 seconds
Agents:
discovery       puppet          rpcutil
Data Plugins:
agent           fstat           puppet
resource
Configuration Management Classes:
No classes applied
Facts:
mcollective => 1
  注意,如果你重启不了或者puppet插件正常加载(也可以通过mcollective.log查看加载是否有错误),那么你需要检查下你的环境变量



RUBYLIB是否存在以及包含 D:\Puppet Labs\Puppet\puppet\lib;D:\Puppet Labs\Puppet\facter\lib
  整个配置过程结束,在puppetserver上进行一次推送试试吧



[iyunv@puppetserver mcollective]# mco puppet -v -I waiwofei runonce
* [ ============================================================> ] 1 / 1

waiwofei                                : OK
{:summary=>      "Started a background Puppet run using the '\"D:\\Puppet Labs\\Puppet\\bin\\puppet.bat\" agent --onetime --color=false --splay --splaylimit 30' command"}

---- rpc stats ----
Nodes: 1 / 1
Pass / Fail: 1 / 0
Start Time: Tue Apr 29 10:36:58 +0800 2014
Discovery Time: 0.00ms
Agent Time: 50.93ms
Total Time: 50.93ms
  
  运行成功,通过puppet dashboard也可以看到运行成功
DSC0000.jpg

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-114338-1-1.html 上篇帖子: Puppet master/agent installation on RHEL7 下篇帖子: puppet插件fact和hiera(puppet自动化系列3)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表