uoregon-multissh 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c50dffc0f04f0205fb1b0cd28c65497c6bd1a788ea2c9980f7e7fd29fa9e6119
4
- data.tar.gz: 7571b3c5ae53384e7cf1279a2ae72fd454ccbb2ac762a1b321aacf8201e70657
3
+ metadata.gz: d3715c72b56b4b20bb515810e186294c20a870b2931f0a27224ded025bd21b31
4
+ data.tar.gz: b3c4f68e47301b098cf1159050092aa11ca94838ee7de1b165087a5dc6a848b3
5
5
  SHA512:
6
- metadata.gz: b0fe50fe1f5cc7211f777e9ce39b3f1f1a65ccb61bebffe6264effc10bbd174d6467c332b9c8c4c262e280308506aef9dcf760673af77d4aa4dbc4e7f45dcb89
7
- data.tar.gz: a12b9c780a98df4fcca029cf41857b7bcdb0455cb066827e30acb16cc54f769671cb3f269c852cbb74cd30d730a4960429546af96104a588c846a6955df6e576
6
+ metadata.gz: e57fa55e276b3bc1601fcfd8c7ff2fba53fdf1854c11a3f828d70436cbf4a28f168eac5e94e5ed8dfd293e62fe3d40b18b15e5bd8d4b64fc78d040d49c5c74fe
7
+ data.tar.gz: c15568482425b969e0e64fec6a456d8ed8ff6cb15ca0288cf9b046ed0d5c57bc93f7318e988e5b399f9a5b3cd862d62f891c88001cad60afbdbcca8fbf1ccd96
data/lib/cli.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require_relative 'credential'
2
2
 
3
3
  class Cli
4
- attr_accessor :username, :password, :key_password, :nodes, :command, :block, :debug, :credential
4
+ attr_accessor :username, :password, :key_password, :nodes, :command, :block, :header_max_length, :debug, :credential
5
5
 
6
6
  def initialize
7
7
 
@@ -15,6 +15,7 @@ class Cli
15
15
  opt.on('--pkey_password "PASSWORD"', 'OPTIONAL: will prompt if needed') { |o| @options[:pkey_password] = o }
16
16
  opt.on('--disable_sudo', 'OPTIONAL: disable_sudo requirement and run as current user') { @options[:disable_sudo] = true }
17
17
  opt.on('--block', 'OPTIONAL: block mode for command ouptut') { @options[:block] = true }
18
+ opt.on('--match_width', 'OPTIONAL: matches hostname width for easier comparison of results') { @options[:match_width] = true }
18
19
  opt.on('--regenerate_config', 'OPTIONAL: regenerate configuration file') { @options[:regenerate_config] = true }
19
20
  opt.on('--debug', 'OPTIONAL: debug mode') { @options[:debug] = true }
20
21
  end
@@ -56,6 +57,8 @@ class Cli
56
57
  @command = parse_command(@options[:command])
57
58
  @block = true if @options[:block]
58
59
 
60
+ @header_max_length = @options[:match_width] ? @nodes.max_by(&:length).length : nil
61
+
59
62
  rescue Interrupt
60
63
  puts "\nCtrl+C Interrupt\n"
61
64
  exit 1
data/lib/multissh.rb CHANGED
@@ -16,14 +16,15 @@ class Multissh < Cli
16
16
  tasks = []
17
17
  @nodes.each do |node|
18
18
  worker = Worker.new(
19
- hostname=node.chomp,
20
- username=@username,
21
- password=@password,
22
- pkey_password=@pkey_password,
23
- sudo_password=@sudo_password,
24
- command=@command,
25
- block=@block,
26
- debug=@debug,
19
+ hostname: node.chomp,
20
+ username: @username,
21
+ password: @password,
22
+ pkey_password: @pkey_password,
23
+ sudo_password: @sudo_password,
24
+ command: @command,
25
+ block: @block,
26
+ header_max_length: @header_max_length,
27
+ debug: @debug,
27
28
  )
28
29
  tasks.append(worker)
29
30
  end
data/lib/worker.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Worker
2
- def initialize(hostname, username, password, pkey_password, sudo_password, command, block, debug)
2
+ def initialize(hostname: nil, username: nil, password: nil, pkey_password: nil, sudo_password: nil, command: nil, block: nil, header_max_length: nil, debug: nil)
3
3
  @hostname = hostname
4
4
  @username = username
5
5
  @password = password
@@ -8,7 +8,9 @@ class Worker
8
8
  @command = command
9
9
  @block = block
10
10
 
11
- @header = "#{hostname} -- "
11
+ @header_begin = hostname
12
+ @header_padding = header_max_length ? " " * (header_max_length - hostname.length) : ""
13
+ @header_end = " -- "
12
14
  @util = Util.new(debug)
13
15
  end
14
16
 
@@ -17,6 +19,8 @@ class Worker
17
19
  @util.show_summary(self)
18
20
 
19
21
  result = ''
22
+ @header = @header_begin + @header_padding + @header_end
23
+
20
24
  begin
21
25
  Net::SSH.start(@hostname, @username, :password => @password, :passphrase => @pkey_password, :non_interactive => true) do |ssh|
22
26
  channel = ssh.open_channel do |channel, success|
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'uoregon-multissh'
3
- spec.version = '0.3.5'
3
+ spec.version = '0.3.6'
4
4
  spec.date = '2019-05-14'
5
5
  spec.summary = "Do all the things everywhere at the same time"
6
6
  spec.description = "Quickly run multiple commands on many boxes at the same time"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uoregon-multissh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Crownover