Class: Multissh

Inherits:
Cli
  • Object
show all
Defined in:
lib/multissh.rb

Instance Attribute Summary

Attributes inherited from Cli

#block, #command, #credential, #debug, #header_max_length, #key_password, #nodes, #password, #username

Instance Method Summary collapse

Methods inherited from Cli

#format_command, #initialize, #parse_command, #parse_nodes

Constructor Details

This class inherits a constructor from Cli

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/multissh.rb', line 15

def run
  tasks = []
  @nodes.each do |node|
    worker = Worker.new(
      hostname: node.chomp, 
      username: @username, 
      password: @password,
      pkey_password: @pkey_password,
      sudo_password: @sudo_password,
      command: @command, 
      block: @block, 
      header_max_length: @header_max_length,
      debug: @debug,
    )
    tasks.append(worker)
  end

  results = Parallel.map(tasks) do |task|
    task.go
  end

  rescue Interrupt
    puts "\nCtrl+C Interrupt\n"
    exit 1

end