Class: Trooper::Runner
- Inherits:
-
Object
- Object
- Trooper::Runner
- Defined in:
- lib/trooper/runner.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
-
#execute ⇒ Object
Public: Executes the strategy across mutiple hosts logging output as it goes.
-
#initialize(strategy, config) ⇒ Runner
constructor
Public: initialize a new Runner.
Constructor Details
#initialize(strategy, config) ⇒ Runner
Public: initialize a new Runner.
strategy - A Trooper::Strategy object to execute. config - A Trooper::Configuration object to use for deployment.
Examples
Runner.new(<Strategy>, <Configuration>) # => <Runner>
Returns a new Runner object.
18 19 20 21 |
# File 'lib/trooper/runner.rb', line 18 def initialize(strategy, config) @strategy, @config = strategy, config @list = strategy.list config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/trooper/runner.rb', line 6 def config @config end |
#list ⇒ Object (readonly)
Returns the value of attribute list.
6 7 8 |
# File 'lib/trooper/runner.rb', line 6 def list @list end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
6 7 8 |
# File 'lib/trooper/runner.rb', line 6 def strategy @strategy end |
Instance Method Details
#execute ⇒ Object
Public: Executes the strategy across mutiple hosts logging output as it goes.
Examples
@runner.execute # => true
Returns a boolean.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/trooper/runner.rb', line 30 def execute Trooper.logger.debug "Configuration\n#{config}" Trooper.logger.strategy strategy.description successful = nil hosts.each do |host| begin Trooper.logger.info "\e[4mRunning on #{host}\n" list.each do |strategy_name, type, name| # strategy_name, type, name commands, = build_commands strategy_name, type, name runner_execute! host, commands, if commands end successful = true Trooper.logger.success "\e[4mAll Actions Completed\n" rescue Exception => e Trooper.logger.error "#{e.class.to_s} : #{e.}\n\n#{e.backtrace.join("\n")}" successful = false break #stop commands running on other servers ensure host.close end end successful end |