Project

General

Profile

mcollective » History » Revision 4

Revision 3 (Laurent Domb, 04/30/2013 03:31 PM) → Revision 4/13 (Laurent Domb, 05/01/2013 09:09 AM)

h1.    mcollective  

 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.  

 h2. Mcollective, Foreman and Puppet PE 

 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.  

 I assume you have followed the guide [[    passenger on Puppet PE and use foreman as an ENC and reporting engine ]]. If so you need to replace, create and edit the following files:  

 <pre> 
 /usr/share/foreman-proxy/config/settings.yml  
 /usr/share/foreman-proxy/lib/proxy/puppet.rb 
 /usr/share/foreman-proxy/lib/proxy/puppet/runner.rb 
 /usr/share/foreman-proxy/lib/puppet_api.rb 
 </pre> 

 In /usr/share/foreman-proxy/config/settings add the following line after the puppet management entry: 

 <pre> 
 # enable MCollective integration 
 :mcollective: true false 
 </pre> 

 Now your puppet pe / foreman installation is ready for a puppet run via foreman host page.  

 Then replace puppet.rb and puppet_api.rb 
 <pre> 
 # rm -f /usr/share/foreman-proxy/lib/proxy/puppet.rb 
 # cd /usr/share/foreman-proxy/lib/proxy/ 
 # wget https://raw.github.com/skottler/smart-proxy/2a7b5fbfcdb3a0e9a4b22d46a09d4bfa2aa0f765/lib/proxy/puppet.rb 
 # rm -f /usr/share/foreman-proxy/lib/puppet_api.rb 
 # cd /usr/share/foreman-proxy/lib/ 
 # wget https://raw.github.com/skottler/smart-proxy/2a7b5fbfcdb3a0e9a4b22d46a09d4bfa2aa0f765/lib/puppet_api.rb 
 </pre> 

 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.   

 <pre> 
 # cd /usr/share/foreman-proxy/lib/proxy/puppet/ 
 # wget https://raw.github.com/skottler/smart-proxy/2a7b5fbfcdb3a0e9a4b22d46a09d4bfa2aa0f765/lib/proxy/puppet/runner.rb 
 </pre> 

 Modify the runner.rb file on line 8 and line 16:  

 <pre> 
   1 module Proxy::Puppet 
   2     class Mcollective 
   3       extend Proxy::Util 
   4 
   5       def self.run(nodes) 
   6         mco_search_path = ["/usr/bin", "/opt/puppet/bin"] 
   7         sudo = which("sudo", "usr/bin") 
   8         sudo = sudo << " -u peadmin" 
   9         mco = which("mco", mco_search_path) 
  10 
  11         unless sudo and mco 
  12           logger.warn "sudo or the mco binary is missing." 
  13           return false 
  14         end 
  15 
  16         mco << " puppetd runonce -I #{nodes}" 
 </pre> 

 h3. Mcollective sudo  

 Create an mcollective sudoers file to allow the foreman proxy to execute mco commands. 

 <pre> 
 Defaults:foreman-proxy !requiretty 
 foreman-proxy ALL=(peadmin) NOPASSWD: /opt/puppet/bin/mco * 
 </pre>