Project

General

Profile

mcollective » History » Version 1

Laurent Domb, 04/30/2013 03:24 PM

1 1 Laurent Domb
h1.  mcollective 
2
3
As adding support for mCollective is currently a work in progress [[ http://projects.theforeman.org/projects/1/wiki/MCollective_integration ]] and primarily focused around the smart-proxy, this how to can change at any time. 
4
5
h2. Mcollective, Foreman and Puppet PE
6
7
As puppet PE comes with mcollective it's fairly easy to make it work with the foreman smart proxy. Sam Kottler wrote a patch (https://github.com/theforeman/smart-proxy/pull/58/files) to integrate mcollective and foreman-proxy. 
8
9
I assume you have followed the guide [[ passenger on Puppet PE ]]. If so you need to replace, create and edit the following files: 
10
11
<pre>
12
/usr/share/foreman-proxy/config/settings.yml 
13
/usr/share/foreman-proxy/lib/proxy/puppet.rb
14
/usr/share/foreman-proxy/lib/proxy/puppet/runner.rb
15
/usr/share/foreman-proxy/lib/puppet_api.rb
16
</pre>
17
18
In /usr/share/foreman-proxy/config/settings add the following line after the puppet management entry:
19
20
<pre>
21
# enable MCollective integration
22
:mcollective: false
23
</pre>
24
25
Then replace puppet.rb and puppet_api.rb
26
<pre>
27
# rm -f /usr/share/foreman-proxy/lib/proxy/puppet.rb
28
# cd /usr/share/foreman-proxy/lib/proxy/
29
# wget https://raw.github.com/skottler/smart-proxy/2a7b5fbfcdb3a0e9a4b22d46a09d4bfa2aa0f765/lib/proxy/puppet.rb
30
# rm -f /usr/share/foreman-proxy/lib/puppet_api.rb
31
# cd /usr/share/foreman-proxy/lib/
32
# wget https://raw.github.com/skottler/smart-proxy/2a7b5fbfcdb3a0e9a4b22d46a09d4bfa2aa0f765/lib/puppet_api.rb
33
</pre>
34
35
The 4th script runner.rb needs a little bit more attention as puppet pe 2.7.2 does not use the mcollective agent puppet. It uses puppetd. Also to be able to query the hosts, all the mcollective commands need to be running in the peadmin user environment.  
36
37
<pre>
38
# cd /usr/share/foreman-proxy/lib/proxy/puppet/
39
# wget https://raw.github.com/skottler/smart-proxy/2a7b5fbfcdb3a0e9a4b22d46a09d4bfa2aa0f765/lib/proxy/puppet/runner.rb
40
</pre>
41
42
Modify the runner.rb file on line 8 and line 16: 
43
44
<pre>
45
  1 module Proxy::Puppet
46
  2   class Mcollective
47
  3     extend Proxy::Util
48
  4
49
  5     def self.run(nodes)
50
  6       mco_search_path = ["/usr/bin", "/opt/puppet/bin"]
51
  7       sudo = which("sudo", "usr/bin")
52
  8       sudo = sudo << " -u peadmin"
53
  9       mco = which("mco", mco_search_path)
54
 10
55
 11       unless sudo and mco
56
 12         logger.warn "sudo or the mco binary is missing."
57
 13         return false
58
 14       end
59
 15
60
 16       mco << " puppetd runonce -I #{nodes}"
61
</pre>
62
63
h3. Mcollective sudo 
64
65
Create an mcollective sudoers file to allow the foreman proxy to execute mco commands.
66
67
<pre>
68
Defaults:foreman-proxy !requiretty
69
foreman-proxy ALL=(peadmin) NOPASSWD: /opt/puppet/bin/mco *
70
</pre>