Sha256: f5c422ec594e4d60fc22892ef874380a4c21aaac5ea829d2e843e549ee5b6a20
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
module Fezzik class HostTask < Rake::Task attr_accessor :roles, :weave_options def initialize(task_name, app) super @host_actions = [] @roles = [] @weave_options = {} end def enhance(deps = nil, &block) @host_actions << block if block_given? super(deps) end def execute(args = nil) return if Rake.application.options.dryrun merged_weave_options = Fezzik.default_weave_options.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, merged_weave_options, &action) rescue Weave::Error => e STDERR.puts "Error running command in HostTask '#{@name}':" abort e.message 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, merged_weave_options, &action) rescue Weave::Error => e STDERR.puts "Error running command in HostTask '#{@name}' with role '#{role}':" abort e.message end end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fezzik-0.8.4 | lib/fezzik/host_task.rb |
fezzik-0.8.3 | lib/fezzik/host_task.rb |