Intro to Using MCollective - PuppetConf 2014

Post on 25-Dec-2014

480 views 0 download

description

Intro to Using MCollective - Devon Peters, Jive Software

transcript

Intro  to  MCollec,ve    

Orchestra,on?  

h3ps://flic.kr/p/g5Z5TU  

Who  am  I?  

h3ps://flic.kr/p/5F1BfM  

h3ps://flic.kr/p/3t5WV  

h3ps://flic.kr/p/6rTurs  

h3ps://flic.kr/p/nvAJDP  

Agents  ==  Sheet  Music  

h3ps://flic.kr/p/4oxUMc  

"SchaRerdeInKoeln"  by  Túrelio  -­‐  Own  work.  Licensed  under  Crea,ve  Commons  A3ribu,on-­‐Share  Alike  2.5  via  Wikimedia  Commons  -­‐  h3p://commons.wikimedia.org/wiki/File:SchaRerdeInKoeln.jpg#mediaviewer/File:SchaRerdeInKoeln.jpg  

h3ps://flic.kr/p/dZMbgg  

Filters  ==  Find  a  Sec4on  

Pu^ng  it  into  ac,on  

S,ll  not  quite  the  Orchestra  

A  way  to  achieve  that…  

#!/bin/bash -e for node in $(mco find --np -C roles::node)

do

echo "restarting ssh on $node"

mco service --np sshd restart -I $node >/dev/null

sleep 2

mco rpc service status service=sshd -I $node -j | \

grep "status.*running" >/dev/null 2>&1

echo "ssh is up on $node" done

#!/usr/bin/ruby

require 'mcollective' include MCollective::RPC

util = rpcclient("rpcutil")

util.progress = false util.class_filter /roles::node/ nodes = []

util.ping.each do |resp| nodes << resp[:sender]

end util.disconnect

status = "" nodes.each do |node| srv = rpcclient("service")

srv.progress = false srv.identity_filter node

puts "restarting sshd on #{node}" srv.restart(:service => "sshd") srv.reset

i = 0

while i < 3 do srv.status(:service => "sshd").each do |resp| status = resp[:data][:status]

end if status == "running"

break end srv.reset

sleep 1 i += 1

end if status != "running"

puts "failed to restart sshd" exit 1

end

puts "ssh is up #{node}" end

Just some info…

NO DEMO

Ques,ons?  

BTW  -­‐  Demo  brought  to  you  by  h3ps://github.com/ripienaar/mcollec,ve-­‐vagrant,  check  it  out.    

Also,  thank  you  R.I.  Pienaar.