### foreman架构的引入7-Foreman结合mcollective完成push动作
**注:**以下内容是在**foreman1.6.3+puppet2.6.2**环境下进行操作。更多配置请参考官网[http://theforeman.org/manuals/1.6/index.html](http://theforeman.org/manuals/1.6/index.html)
在foreman-proxy的1.6.3版本,至少提供了以下五种触发puppet agent命令的工具,默认使用的是puppetrun,不过已经过时,这里介绍如何使用mcollective进行触发,下个章节会介绍如何使用puppetssh触发。
~~~
# puppetrun (for puppetrun/kick, deprecated in Puppet 3)
# mcollective (uses mco puppet)
# puppetssh (run puppet over ssh)
# salt (uses salt puppet.run)
# customrun (calls a custom command with args)
~~~
在整个测试之前,首先要保障你的mco+mq在命令行操作的情况下是OK的。如果没有OK或者不懂什么是mco+mq,请参考之前的文章。
如何是OK的?如下:
~~~
[root@puppetmaster162 yum.repos.d]# mco puppet -v runonce
Discovering hosts using the mc method for 2 second(s) .... 1
* [ ============================================================> ] 1 / 1
puppetmaster162.kisspuppet.com : OK
{:summary=> "Started a Puppet run using the 'puppet agent --test --color=false --splay --splaylimit 30' command"}
---- rpc stats ----
Nodes: 1 / 1
Pass / Fail: 1 / 0
Start Time: Wed Dec 17 16:22:15 +0800 2014
Discovery Time: 2004.22ms
Agent Time: 71.49ms
Total Time: 2075.70ms
~~~
### 1、在Foreman中开启puppet插件的puppetrun功能
### 2、配置foreman-proxy代理的puppet的puppet_provider
~~~
[root@puppetmaster162 ~]# vim /etc/foreman-proxy/settings.d/puppet.yml
---
# Puppet management
:enabled: true
:puppet_conf: /etc/puppet/puppet.conf
# valid providers:
# puppetrun (for puppetrun/kick, deprecated in Puppet 3)
# mcollective (uses mco puppet)
# puppetssh (run puppet over ssh)
# salt (uses salt puppet.run)
# customrun (calls a custom command with args)
:puppet_provider: mcollective
...
~~~
### 3、配置sudoer,添加mco命令
~~~
[root@puppetmaster162 ~]# vim /etc/sudoers.d/foreman-proxy
foreman-proxy ALL = NOPASSWD : /usr/bin/puppet cert *, /usr/bin/mco puppet runonce *
Defaults:foreman-proxy !requiretty
[root@puppetmaster162 ~]# /etc/init.d/foreman-proxy restart
Stopping foreman-proxy: [ OK ]
Starting foreman-proxy: [ OK ]
~~~
### 4、页面测试puppetrun按钮
成功之后的显示
### 5、查看报告看更详细的信息
~~~
#可以通过日志查看执行情况
[root@puppetmaster162 yum.repos.d]# tailf /var/log/foreman-proxy/proxy.log
192.168.20.11 - - [17/Dec/2014 16:25:36] "POST /run HTTP/1.1" 200 - 0.5454
以上
[root@puppetmaster162 ~]# cat /etc/foreman-proxy/settings.yml
...
:log_file: /var/log/foreman-proxy/proxy.log
# valid options are
# WARN, DEBUG, Error, Fatal, INFO, UNKNOWN
:log_level: DEBUG #开启debug模式,显示更详细的信息,排错的时候使用。1.5版本之前默认是开启的
[root@puppetmaster162 yum.repos.d]# tailf /var/log/foreman-proxy/proxy.log
I, [2014-12-17T16:27:43.148519 #24337] INFO -- : 'foreman_proxy' settings were initialized with default values: :enabled: true
W, [2014-12-17T16:27:43.155592 #24337] WARN -- : Couldn't find settings file /etc/foreman-proxy/settings.d/facts.yml. Using default settings.
I, [2014-12-17T16:27:43.155860 #24337] INFO -- : 'facts' settings were initialized with default values: :enabled: true
I, [2014-12-17T16:27:43.163012 #24337] INFO -- : 'dns' module is disabled.
I, [2014-12-17T16:27:43.163513 #24337] INFO -- : 'tftp' module is disabled.
I, [2014-12-17T16:27:43.163933 #24337] INFO -- : 'dhcp' module is disabled.
I, [2014-12-17T16:27:43.579571 #24337] INFO -- : 'puppet' settings were initialized with default values: :puppetdir: /etc/puppet
I, [2014-12-17T16:27:43.583486 #24337] INFO -- : 'bmc' module is disabled.
I, [2014-12-17T16:27:43.583655 #24337] INFO -- : 'chefproxy' module is disabled.
I, [2014-12-17T16:27:43.583934 #24337] INFO -- : 'realm' module is disabled.
D, [2014-12-17T16:28:15.059328 #24344] DEBUG -- : about to execute: /usr/bin/sudo -u root /usr/bin/mco puppet runonce -I puppetmaster162.kisspuppet.com
192.168.20.11 - - [17/Dec/2014 16:28:15] "POST /run HTTP/1.1" 200 - 0.5468
~~~
失败的情况如下:
~~~
[root@puppetmaster162 ~]# tailf /var/log/foreman-proxy/proxy.log
I, [2014-12-17T16:27:43.163933 #24337] INFO -- : 'dhcp' module is disabled.
I, [2014-12-17T16:27:43.579571 #24337] INFO -- : 'puppet' settings were initialized with default values: :puppetdir: /etc/puppet
I, [2014-12-17T16:27:43.583486 #24337] INFO -- : 'bmc' module is disabled.
I, [2014-12-17T16:27:43.583655 #24337] INFO -- : 'chefproxy' module is disabled.
I, [2014-12-17T16:27:43.583934 #24337] INFO -- : 'realm' module is disabled.
D, [2014-12-17T16:28:15.059328 #24344] DEBUG -- : about to execute: /usr/bin/sudo -u root /usr/bin/mco puppet runonce -I puppetmaster162.kisspuppet.com
192.168.20.11 - - [17/Dec/2014 16:28:15] "POST /run HTTP/1.1" 200 - 0.5468
D, [2014-12-17T16:32:56.924849 #24344] DEBUG -- : about to execute: /usr/bin/sudo -u root /usr/bin/mco puppet runonce -I puppetmaster162.kisspuppet.com
192.168.20.11 - - [17/Dec/2014 16:32:57] "POST /run HTTP/1.1" 200 - 0.6095
D, [2014-12-17T16:32:57.878231 #24344] DEBUG -- : about to execute: /usr/bin/sudo -u root /usr/bin/mco puppet runonce -I foreman163.kisspuppet.com
W, [2014-12-17T16:33:20.364704 #24344] WARN -- : Non-null exit code when executing '/usr/bin/sudo-uroot/usr/bin/mcopuppetrunonce-Iforeman163.kisspuppet.com'
E, [2014-12-17T16:33:20.368673 #24344] ERROR -- : Failed puppet run: Check Log files
192.168.20.11 - - [17/Dec/2014 16:33:20] "POST /run HTTP/1.1" 500 34 22.4920
~~~
**备注:**Foreman在命令执行后的显示这块做的其实很不好的,如何能够将所有节点执行的情况动态或者显示在界面上就更好了!
- 序
- 第一章:Puppet基础篇
- 编写此系列文档的目的
- 如何学习和使用Puppet
- 安装Puppet前期的准备工作
- 安装、配置并使用Puppet
- 如何建立master和agent之间的认证关系
- Puppet更新方式的选型
- 编写第一个完整测试模块puppet
- 编写第二个完整测试模块yum
- Puppetmaster多环境配置
- 自定义fact实现的四种方式介绍
- 第二章:Puppet扩展篇
- 自定义fact结合ENC(hirea)的应用实践
- 如何使用虚拟资源解决puppet冲突问题
- 如何扩展master的SSL传输性能(apache)
- 如何扩展master的SSL传输性能(nginx)
- 通过多进程增强master的负载均衡能力(nginx+mongrel)
- 通过横向扩展puppetmaster增加架构的灵活性
- puppet代码与版本控制系统的结合
- Puppet dashboard的部署及测试
- 第三章:MCollective架构篇
- MCollecitve架构的引入
- MCollective+MQ架构的部署
- Puppet插件的部署及测试
- MCollective各种插件的部署及测试
- MCollective安全性设计
- MQ的安全性设计
- 多MQ下MCollective高可用部署
- 第四章:Foreman架构的引入
- Foreman作为自动化运维工具为什么会如此强大
- 安装前环境准备
- 安装Foreman1.5架构(all-in-one)
- 安装Foreman1.6架构(foreman与puppetmaster分离)
- 安装Foreman1.7架构(源码,仅测试使用)
- 整合puppetmaster
- Foreman结合mcollective完成push动作
- Foreman结合puppetssh完成push动作
- Foreman的ENC环境与fact环境的对比
- hostgroup如何转换为本地的fact
- 智能变量与puppet模块参数化类的结合
- Foreman报告系统的使用
- Foreman-proxy如何做负载均衡
- Foreman上如何展现代码及文件内容
- Foreman如何和虚拟化管理软件结合
- 如何借助Foreman完成自动化部署操作系统(一)
- 如何借助Foreman完成自动化部署操作系统(二)
- Foreman CLI(Hammer)工具的使用
- Foreman目前的不足之处