Skip to content

Instantly share code, notes, and snippets.

@ploubser
Created November 11, 2013 16:15
Show Gist options
  • Save ploubser/7415779 to your computer and use it in GitHub Desktop.
Save ploubser/7415779 to your computer and use it in GitHub Desktop.
require 'mcollective'
require 'pp'
require 'json'
# Find the config file. Right now I'm guessing
# This is not going to work in the longrun.
config_file = "/etc/mcollective/client.cfg"
agent = ARGV[0]
action = ARGV[1]
# Arguments go here
config = MCollective::Config.instance
config.loadconfig(config_file)
MCollective::PluginManager.loadclass("MCollective::Agent::#{agent.capitalize}")
agent = MCollective::PluginManager.create_instance("MCollective::Agent::#{agent.capitalize}")
message = {:body => {:action => action, :data => {}}}
result = agent.handlemsg(message, nil)
puts result[:data].to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment