Class: Puppet::Run
Overview
A basic class for running the agent. Used by puppetrun to kick off agents remotely.
Defined Under Namespace
Instance Attribute Summary collapse
-
#background ⇒ Object
readonly
Returns the value of attribute background.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #agent ⇒ Object
- #background? ⇒ Boolean
-
#initialize(options = {}) ⇒ Run
constructor
A new instance of Run.
- #log_run ⇒ Object
- #run ⇒ Object
- #to_pson ⇒ Object
Methods included from Indirector
Constructor Details
#initialize(options = {}) ⇒ Run
Returns a new instance of Run.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet/run.rb', line 21 def initialize( = {}) if .include?(:background) @background = [:background] .delete(:background) end = [:tags, :ignoreschedules] .each do |key, value| raise ArgumentError, "Run does not accept #{key}" unless .include?(key) end @options = end |
Instance Attribute Details
#background ⇒ Object (readonly)
Returns the value of attribute background.
11 12 13 |
# File 'lib/puppet/run.rb', line 11 def background @background end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/puppet/run.rb', line 11 def @options end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
11 12 13 |
# File 'lib/puppet/run.rb', line 11 def status @status end |
Class Method Details
.from_pson(pson) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/puppet/run.rb', line 65 def self.from_pson( pson ) = {} pson.each do |key, value| [key.to_sym] = value end new() end |
Instance Method Details
#agent ⇒ Object
13 14 15 |
# File 'lib/puppet/run.rb', line 13 def agent Puppet::Agent.new(Puppet::Configurer) end |
#background? ⇒ Boolean
17 18 19 |
# File 'lib/puppet/run.rb', line 17 def background? background end |
#log_run ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/puppet/run.rb', line 35 def log_run msg = "" msg += "triggered run" % if [:tags] msg += " with tags #{[:tags].inspect}" end msg += " ignoring schedules" if [:ignoreschedules] Puppet.notice msg end |
#run ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/puppet/run.rb', line 46 def run if agent.running? @status = "running" return self end log_run if background? Thread.new { agent.run() } else agent.run() end @status = "success" self end |
#to_pson ⇒ Object
74 75 76 |
# File 'lib/puppet/run.rb', line 74 def to_pson @options.merge(:background => @background).to_pson end |