[rpuppet] Got rid of hardcoded config and paths
This commit is contained in:
parent
5cf01b4eec
commit
9e3de39715
@ -1,38 +0,0 @@
|
||||
require 'puppet/indirector/terminus'
|
||||
require 'puppet/util'
|
||||
|
||||
class Puppet::Indirector::Orchestrator < Puppet::Indirector::Terminus
|
||||
# Look for external node definitions.
|
||||
def find(request)
|
||||
name = request.key
|
||||
external_command = command
|
||||
|
||||
# Make sure it's an arry
|
||||
raise Puppet::DevError, "Exec commands must be an array" unless external_command.is_a?(Array)
|
||||
|
||||
# Make sure it's fully qualified.
|
||||
raise ArgumentError, "You must set the exec parameter to a fully qualified command" unless Puppet::Util.absolute_path?(external_command[0])
|
||||
|
||||
# Add our name to it.
|
||||
external_command << name
|
||||
begin
|
||||
output = execute(external_command, :combine => false)
|
||||
rescue Puppet::ExecutionFailure => detail
|
||||
raise Puppet::Error, "Failed to find #{name} via exec: #{detail}"
|
||||
end
|
||||
|
||||
if output =~ /\A\s*\Z/ # all whitespace
|
||||
Puppet.debug "Empty response for #{name} from #{self.name} terminus"
|
||||
return nil
|
||||
else
|
||||
return output
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Proxy the execution, so it's easier to test.
|
||||
def execute(command, arguments)
|
||||
Puppet::Util::Execution.execute(command,arguments)
|
||||
end
|
||||
end
|
@ -9,9 +9,9 @@ metadata :name => "rpuppet",
|
||||
action "run", :description => "Invoke a puppet run" do
|
||||
input :data,
|
||||
:prompt => "data",
|
||||
:description => "Data to pass into puppet run",
|
||||
:description => "Data encoded in JSON to pass into puppet run",
|
||||
:type => :string,
|
||||
:validation => '^[a-zA-Z0-9_]+$',
|
||||
:validation => '.*',
|
||||
:optional => false,
|
||||
:maxlength => 0
|
||||
|
||||
|
@ -1,15 +1,17 @@
|
||||
require 'singleton'
|
||||
$LOAD_PATH << File.join(File.dirname(__FILE__))
|
||||
require 'puppet/util/command_line'
|
||||
require 'puppet/application'
|
||||
require 'puppet'
|
||||
load '/vagrant/mcagent/rapply.rb' # Don't do require here: it requires Puppet.features, which is not available at this moment yet
|
||||
require '/vagrant/mcagent/node_indirector.rb'
|
||||
|
||||
load 'rapply.rb' # Don't do require here: it requires Puppet.features, which is not available at this moment yet
|
||||
require 'node_indirector'
|
||||
|
||||
module Astute
|
||||
def self.set_config(cfg)
|
||||
@config = cfg
|
||||
end
|
||||
|
||||
# Node indirector calls this method to get configuration
|
||||
def self.get_config
|
||||
@config
|
||||
end
|
||||
@ -20,10 +22,14 @@ module MCollective
|
||||
class Rpuppet < RPC::Agent
|
||||
|
||||
action "run" do
|
||||
cmdline = Puppet::Util::CommandLine.new("puppet", ["apply", "/root/site.pp", "--modulepath=/vagrant/puppet", "--debug", "--logdest=/tmp/puppetlog"])
|
||||
validate :data, String
|
||||
config = JSON.parse(request[:data])
|
||||
Log.info("Received configuration: #{config.inspect}")
|
||||
Astute.set_config(config)
|
||||
|
||||
`echo > /opt/site.pp`
|
||||
cmdline = Puppet::Util::CommandLine.new("puppet", ["apply", "/opt/site.pp", "--modulepath=/opt/fuel", "--debug", "--logdest=/var/log/puppetrun.log"])
|
||||
Puppet.settings.initialize_global_settings(cmdline.args) unless Puppet.settings.global_defaults_initialized?
|
||||
#validate :data, String
|
||||
Astute.set_config({"environment"=>"production", "parameters"=>nil, "classes"=>{"nailytest"=>{"role"=>["controller"]}}})
|
||||
|
||||
app = Puppet::Application::Rapply.new(cmdline)
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
require 'puppet/util/command_line'
|
||||
require 'puppet/application'
|
||||
require 'puppet'
|
||||
load '/vagrant/mcagent/rapply.rb' # Don't do require here: it requires Puppet.features, which is not available at this moment yet
|
||||
require '/vagrant/mcagent/node_indirector.rb'
|
||||
|
||||
module Astute
|
||||
def self.set_config(cfg)
|
||||
@config = cfg
|
||||
end
|
||||
|
||||
def self.get_config
|
||||
@config
|
||||
end
|
||||
end
|
||||
|
||||
cmdline = Puppet::Util::CommandLine.new("puppet", ["apply", "/root/site.pp", "--modulepath=/vagrant/puppet", "--debug", "--logdest=/tmp/puppet.log"])
|
||||
Puppet.settings.initialize_global_settings(cmdline.args)
|
||||
|
||||
Astute.set_config({"environment"=>"production", "parameters"=>nil, "classes"=>{"nailytest"=>{"role"=>["controller"]}}})
|
||||
|
||||
app = Puppet::Application::Rapply.new(cmdline)
|
||||
|
||||
# TODO: what are these plugins for ??
|
||||
#Puppet::Plugins.on_application_initialization(:application_object => self)
|
||||
app.run
|
Loading…
Reference in New Issue
Block a user