Class: Fezzik::HostTask
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- Fezzik::HostTask
- Defined in:
- lib/fezzik/host_task.rb
Instance Attribute Summary collapse
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#weave_options ⇒ Object
Returns the value of attribute weave_options.
Instance Method Summary collapse
- #enhance(deps = nil, &block) ⇒ Object
- #execute(args = nil) ⇒ Object
-
#initialize(task_name, app) ⇒ HostTask
constructor
A new instance of HostTask.
Constructor Details
#initialize(task_name, app) ⇒ HostTask
Returns a new instance of HostTask.
5 6 7 8 9 10 |
# File 'lib/fezzik/host_task.rb', line 5 def initialize(task_name, app) super @host_actions = [] @roles = [] @weave_options = {} end |
Instance Attribute Details
#roles ⇒ Object
Returns the value of attribute roles.
3 4 5 |
# File 'lib/fezzik/host_task.rb', line 3 def roles @roles end |
#weave_options ⇒ Object
Returns the value of attribute weave_options.
3 4 5 |
# File 'lib/fezzik/host_task.rb', line 3 def @weave_options end |
Instance Method Details
#enhance(deps = nil, &block) ⇒ Object
12 13 14 15 |
# File 'lib/fezzik/host_task.rb', line 12 def enhance(deps = nil, &block) @host_actions << block if block_given? super(deps) end |
#execute(args = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fezzik/host_task.rb', line 17 def execute(args = nil) return if Rake.application..dryrun = Fezzik..merge(@weave_options).merge(:args => [self, args]) if @roles.empty? hosts = Fezzik.get(:domain).map { |domain| "#{Fezzik.get(:user)}@#{domain}" } @@connection_pool ||= Weave::ConnectionPool.new @host_actions.each do |action| begin @@connection_pool.execute_with(hosts, , &action) rescue Weave::Error => e STDERR.puts "Error running command in HostTask '#{@name}':" abort e. end end else @roles.each do |role| Fezzik.with_role(role) do hosts = Fezzik.get(:domain).map { |domain| "#{Fezzik.get(:user)}@#{domain}" } @@role_connection_pools ||= {} @@role_connection_pools[role] ||= Weave::ConnectionPool.new @host_actions.each do |action| begin @@role_connection_pools[role].execute_with(hosts, , &action) rescue Weave::Error => e STDERR.puts "Error running command in HostTask '#{@name}' with role '#{role}':" abort e. end end end end end end |