Thursday, 30 April 2015

Mcollective sadness

Mcollective ... why, why?
aka marionette collective - orchestration api
lots of noted filched from puppetlabs
mcollective - overly complex framework that tries to let you run some paralell jobs - really bad implementation and overengineered! Its really one of the reasons I use ansible or pdsh to run parallel jobs!

But hey - some quick notes for me as I'm sometimes forced to use it.
add epel repo
yum install mcollective activemq (really, REALLY?!!) mcollective-client
service blah start
can also do a puppet module install mcollective...
on clients - yum -y install mcollective
edit /etc/mcollective/agent.cfg (or better still put this all under puppet control)

mco ping => pings all mco hosts
mco ping --with-fact operatingsystem=RedHat => pings all mc hosts whos os is rh
mco find --with-class httpd => returns all hosts with httpd class
mco help => obvious
stuart ah \> mco help
The Marionette Collective version 2.6.0.7
  completion      Helper for shell completion systems
  facts           Reports on usage for a specific fact
  find            Find hosts using the discovery system matching filter criteria
  help            Application list and help
  inventory       General reporting tool for nodes, collectives and subcollectives
  package         Install, uninstall, update, purge and perform other actions to packages
  ping            Ping all nodes
  plugin          MCollective Plugin Application
  puppet          Schedule runs, enable, disable and interrogate the Puppet Agent
  rpc             Generic RPC agent client application
  service         Manages system services
stuart ah \>
stuart ah \> mco help inventory
General reporting tool for nodes, collectives and subcollectives
Application Options
        --script SCRIPT              Script to run
        --list-collectives, --lc     List all known collectives
        --collective-graph, --cg, --map MAP
                                     Create a DOT graph of all collectives
RPC Options
        --np, --no-progress          Do not show the progress bar
    -1, --one                        Send request to only one discovered nodes
....

rpc app is quite good:
% mco rpc service start service=httpd

% mco plugin doc
Please specify a plugin. Available plugins are:

Agents:
package Install and uninstall software packages
puppetd Run puppet agent, get its status, and enable/disable it
rpcutil General helpful actions that expose stats and internals to SimpleRPC clients
service Agent to manage services
Here are a number of examples of this with short descriptions of each filter:
# all machines with the service agent
% mco ping -A service
% mco ping --with-agent service

# all machines with the apache class on them
% mco ping -C apache
% mco ping --with-class apache

# all machines with a class that match the regular expression
% mco ping -C /service/

# all machines in the UK
% mco ping -F country=uk
% mco ping --with-fact country=uk

# all machines in either UK or USA
% mco ping -F "country=/uk|us/"

# just the machines called dev1 or dev2
% mco ping -I dev1 -I dev2

# all machines in the domain foo.com
% mco ping -I /foo.com$/


Note: You can use a shortcut to combine Class and Fact filters:
# all machines with classes matching /apache/ in the UK
% mco ping -W "/apache/ location=uk"

The -S switch also allows for negative matches using not or !:
% mco ping -S "environment=development and !customer=acme"
% mco ping -S "environment=development and not customer=acme"

Filtering Using Data Plugins

As of version 2.1.0, custom data plugins can also be used to create complex filters:
% mco ping -S "fstat('/etc/hosts').md5=/baa3772104/ and environment=development"
This will search for the md5 hash of a specific file with matches restricted to the development environment. Note that as before, regular expressions can also be used.
As with agents, you can also discover which plugins are available for use:
% mco plugin doc

but honestly - look at ansible or pdsh to do most of this and more, a lot more simply!!

No comments:

Post a Comment

bash best practices

Bash best practices A few hints on bash best practice: * use #!/usr/bin/env bash .. this is more portable but you cant rely on a spe...