I have setup a cluster using puppet. Now I need to call call puppet agents for puppet master. For that I am planing to use MCollective. I have another requirement, need to call MCollective from a java client in order to achieve change client configurations from master and restart the servers. Is there a way to do it?. Thanks, Irham
Asked
Active
Viewed 201 times
0
-
See this https://groups.google.com/forum/#!topic/mcollective-users/yzJcOZa0v3Y – Subodh Joshi Aug 07 '15 at 06:26
1 Answers
1
I solved the problem by using jruby. I installed the ruby gems mcollective-client,json and jruby-openssl using rvm. In the following example I am calling a simple mco puppet runonce
Java code
ScriptingContainer ruby = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
Object result = ruby.runScriptlet(PathType.ABSOLUTE,"/opt/ruby_test.rb");
Ruby code
require 'rubygems'
require 'mcollective'
include MCollective::RPC
mc = rpcclient("puppet")
printrpc mc.runonce()
mc.disconnect

irham iqbal
- 41
- 3