A basic class for running the agent. Used by `puppet kick` to kick off agents remotely.
# File lib/puppet/run.rb, line 66 def self.from_pson( pson ) options = { :pluginsync => Puppet[:pluginsync] } pson.each do |key, value| options[key.to_sym] = value end new(options) end
# File lib/puppet/run.rb, line 22 def initialize(options = {}) if options.include?(:background) @background = options[:background] options.delete(:background) end valid_options = [:tags, :ignoreschedules, :pluginsync] options.each do |key, value| raise ArgumentError, "Run does not accept #{key}" unless valid_options.include?(key) end @options = options end
# File lib/puppet/run.rb, line 13 def agent # Forking disabled for "puppet kick" runs Puppet::Agent.new(Puppet::Configurer, false) end
# File lib/puppet/run.rb, line 18 def background? background end
# File lib/puppet/run.rb, line 36 def log_run msg = "" msg += "triggered run" % if options[:tags] msg += " with tags #{options[:tags].inspect}" end msg += " ignoring schedules" if options[:ignoreschedules] Puppet.notice msg end
# File lib/puppet/run.rb, line 47 def run if agent.running? @status = "running" return self end log_run if background? Thread.new { agent.run(options) } else agent.run(options) end @status = "success" self end
# File lib/puppet/run.rb, line 75 def to_pson @options.merge(:background => @background).to_pson end