Class: Phase::SSH::BastionCoordinator

Inherits:
Object
  • Object
show all
Defined in:
lib/phase/kit/ssh/bastion_coordinator.rb

Instance Method Summary collapse

Constructor Details

#initialize(bastion, destination_hosts) ⇒ BastionCoordinator

Returns a new instance of BastionCoordinator.



5
6
7
8
# File 'lib/phase/kit/ssh/bastion_coordinator.rb', line 5

def initialize(bastion, destination_hosts)
  @bastion = bastion
  @destination_hosts = destination_hosts
end

Instance Method Details

#each(options = {}, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/phase/kit/ssh/bastion_coordinator.rb', line 10

def each(options = {}, &block)
  if hosts
    queue = Queue.new
    @destination_hosts.each {|host| queue << hosts }

    options = default_options.merge(options)
    options[:address_queue] = queue

    case options[:in]
    when :parallel then ::Phase::SSH::Runners::Parallel
    when :sequence then ::Phase::SSH::Runners::Sequential
    when :groups   then ::Phase::SSH::Runners::Group
    else
      raise RuntimeError, "Don't know how to handle run style #{options[:in].inspect}"
    end.new([@bastion] * @destination_hosts.count, options, &block).execute
  else
    Runners::Null.new(hosts, options, &block).execute
  end
end