+ All Categories
Home > Technology > Puppet Camp London 2014: MCollective as an Integration Layer

Puppet Camp London 2014: MCollective as an Integration Layer

Date post: 24-May-2015
Category:
Upload: puppet-labs
View: 708 times
Download: 5 times
Share this document with a friend
Description:
MCollective as an Integration Layer by Jon Topper
Popular Tags:
30
MCollective as an integration layer Jon Topper The Scale Factory
Transcript
Page 1: Puppet Camp London 2014: MCollective as an Integration Layer

MCollective as an integration layer

Jon Topper The Scale Factory

Page 2: Puppet Camp London 2014: MCollective as an Integration Layer

MCollective

a framework to build server orchestration

or parallel job execution systems.

Page 3: Puppet Camp London 2014: MCollective as an Integration Layer

MCollective

not simply a fancy SSH “for loop”“

Page 4: Puppet Camp London 2014: MCollective as an Integration Layer

MCollective

Servers

MiddlewareClient

Page 5: Puppet Camp London 2014: MCollective as an Integration Layer

MCollective

Servers

MiddlewareClient

Page 6: Puppet Camp London 2014: MCollective as an Integration Layer

Finding Servers

Page 7: Puppet Camp London 2014: MCollective as an Integration Layer

Check Service Status

Page 8: Puppet Camp London 2014: MCollective as an Integration Layer

Check Package Versions

Page 9: Puppet Camp London 2014: MCollective as an Integration Layer

Still looks a bit like a fancy SSH “for loop”

Page 10: Puppet Camp London 2014: MCollective as an Integration Layer

a framework to build server orchestration

or parallel job execution systems.

Page 11: Puppet Camp London 2014: MCollective as an Integration Layer
Page 12: Puppet Camp London 2014: MCollective as an Integration Layer

Zabbix

• Distributed monitoring system

• Fetches time series data - can alert on anomaly

• Uses MySQL

• Multiple data sources:

• Zabbix agent / sender

• SNMP poll / traps

• JMX

Page 13: Puppet Camp London 2014: MCollective as an Integration Layer

Zabbix

Page 14: Puppet Camp London 2014: MCollective as an Integration Layer

Zabbix

Page 15: Puppet Camp London 2014: MCollective as an Integration Layer

ZCollective

zcollective —zabbix-api-url \! http://localhost/api_jsonrpc.php

Page 16: Puppet Camp London 2014: MCollective as an Integration Layer

ZCollective

include MCollective::RPC!!mc = rpcclient("rpcutil", :debug => true)!!mc.discover.sort.each do |host|!! inventory = mc.custom_request( ! "inventory", {}, host,! { "identity" => host }! ).first!! do_some_zabbix_magic(inventory)!!end

Page 17: Puppet Camp London 2014: MCollective as an Integration Layer

ZCollective

def do_some_zabbix_magic(inventory)!! # If the host isn’t added to Zabbix! # Add the host using the API! # For each Puppet class on this host! # If there’s a Zabbix template by this name! # Assign that template to the host.! # end! # end! # end!! # If the host is already in Zabbix! # Make sure all templates correctly assigned! # end !!end

Page 18: Puppet Camp London 2014: MCollective as an Integration Layer

ZCollective

Page 19: Puppet Camp London 2014: MCollective as an Integration Layer

ZCollective

Page 20: Puppet Camp London 2014: MCollective as an Integration Layer

ZCollective

https://github.com/scalefactory/zcollective

Page 21: Puppet Camp London 2014: MCollective as an Integration Layer

Traditional Deployment

Page 22: Puppet Camp London 2014: MCollective as an Integration Layer

sf-deploy

Latest: Deployed:

aaa1 aaa1

Page 23: Puppet Camp London 2014: MCollective as an Integration Layer

sf-deploy

Latest: Deployed:

aaa1 aaa1

Page 24: Puppet Camp London 2014: MCollective as an Integration Layer

sf-deploy

Latest: Deployed: aaa1

aaa2

Page 25: Puppet Camp London 2014: MCollective as an Integration Layer

sf-deploy

Latest: Deployed:

aaa2 aaa2

Page 26: Puppet Camp London 2014: MCollective as an Integration Layer

Code

class MCollective::Application::Sfdeploy < MCollective::Application!! def main!! action = configuration[:action]!! mc = rpcclient("sfdeploy")!! printrpc mc.send(! action,! :application => configuration[:application],! :branch => configuration[:branch],! :tag => configuration[:tag],! :groups => configuration[:groups],! :options => options! )!! printrpcstats! end

Page 27: Puppet Camp London 2014: MCollective as an Integration Layer

Code

module MCollective! module Agent! class Sfdeploy < RPC::Agent!! all_actions.each do |act|! action act do!! sf_deploy = config.pluginconf["sfdeploy.binary"] || "sf-deploy"! deploy_user = config.pluginconf["sfdeploy.user"]|| nil!! command = "#{sf_deploy} -a #{request[:application]} -v "! command << "-b #{request[:branch]} " if request[:branch]! command << "-t #{request[:tag]} " if request[:tag]! command << "-g #{request[:groups]} " if request[:groups]! command << act!! if deploy_user! to_run = "su #{deploy_user} -c \"#{command}\""! else! to_run = command! end

Page 28: Puppet Camp London 2014: MCollective as an Integration Layer

ZCollective

https://github.com/scalefactory/sf-deploy

Page 29: Puppet Camp London 2014: MCollective as an Integration Layer

Resources

http://docs.puppetlabs.com/mcollective/

Page 30: Puppet Camp London 2014: MCollective as an Integration Layer

http://www.scalefactory.com/

[email protected]

@jtopper

scalefactory


Recommended