opswalrus 1.0.95 → 1.0.97

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: 95840cd4d5d5c4e6931039eb2fa780183c17a6c88fde247f8d425855d0a2ff0e
4
- data.tar.gz: 97ba07f54f39a995982edd6f0ac6497d22b6c3063763379d06a4a9294620b583
3
+ metadata.gz: ccf8e333c2a08306ce5afc14a557c69fe01d8681ffeb5e3957b80b09b68bcafa
4
+ data.tar.gz: b8d586b564c368d7e055746c515c7ea5883765b4a5ca3a9d389f89cd04e06e2c
5
5
  SHA512:
6
- metadata.gz: cc97ad6aa85c13f9fc990d57754e6930464c7a7a4379bb7342ae73ac9cbd75ceb5fb8e9311b28dbdfd896b90b7e0fb068398ce9868e22b35f689611a1f24079d
7
- data.tar.gz: 74f423605ce4dbe496c839fa93fed03cf6ae7c49bbbe12fa655b7bfe187af1221d007263819f9cce0cb1f222ee15c37787aff2492a3737bab281b9dff87ac23f
6
+ metadata.gz: 2d7a74e6e3872014452eaa8a19203e1da2b81c9af00c9a6e5f0499caff2a3309f18af2122e00097e7276d80bcd89fb937ab3de7e3b01373187611387e0e23b38
7
+ data.tar.gz: 5b24d54d03bbb5f9bdd03f2d5ddd1644f94819e54803b6d51f5812f5a8758c31f24a58b273c1d42600f00788c0b4e5777e8e3204a8c3a061e10e532c5a150ac9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- opswalrus (1.0.95)
4
+ opswalrus (1.0.97)
5
5
  activesupport (~> 7.0)
6
6
  bcrypt_pbkdf (~> 1.1)
7
7
  binding_of_caller (~> 1.0)
@@ -1,5 +1,7 @@
1
1
  # ssh_noprep in: :sequence do
2
- ssh_noprep do
2
+ host_to_value_map = ssh_noprep do
3
3
  puts "Bootstrapping #{to_s} (alias=#{self.alias})"
4
4
  _bootstrap_host(true)
5
5
  end
6
+
7
+ host_to_value_map.transform_keys(&:to_s)
@@ -10,7 +10,7 @@ timeout = params.timeout.integer!(default: 300)
10
10
 
11
11
  delay = 1 if delay < 1
12
12
 
13
- ssh_noprep in: :sequence do
13
+ host_to_value_map = ssh_noprep in: :sequence do
14
14
  # ssh_noprep do
15
15
 
16
16
  # survey of command options:
@@ -62,3 +62,5 @@ ssh_noprep in: :sequence do
62
62
  # }
63
63
  reboot(delay: delay, sync: sync, timeout: timeout)
64
64
  end
65
+
66
+ host_to_value_map.transform_keys(&:to_s)
@@ -2,9 +2,11 @@ params:
2
2
  ops_file: OpsFile
3
3
  operation_kv_args: array string
4
4
  ...
5
- ssh in: :sequence do
5
+ host_to_value_map = ssh in: :sequence do
6
6
  # ssh_noprep do
7
7
  # puts params.stringify_keys!
8
8
  # desc "Running `#{params.ops_file.ops_file_path} #{params.operation_kv_args.join(' ')}` on #{to_s} (alias=#{self.alias})"
9
9
  _invoke_remote(params.ops_file, *params.operation_kv_args)
10
10
  end
11
+
12
+ host_to_value_map.transform_keys(&:to_s)
@@ -1,9 +1,11 @@
1
1
  params:
2
2
  command: string
3
3
  ...
4
- ssh_noprep in: :sequence do
4
+ host_to_value_map = ssh_noprep in: :sequence do
5
5
  # ssh_noprep do
6
6
  command = params.command
7
7
  desc "Running `#{command}` on #{to_s} (alias=#{self.alias})"
8
8
  shell(command)
9
9
  end
10
+
11
+ host_to_value_map.transform_keys(&:to_s)
data/lib/opswalrus/app.rb CHANGED
@@ -231,7 +231,10 @@ module OpsWalrus
231
231
  result = op.run([], params_json_hash: params)
232
232
  # puts "result class=#{result.class}"
233
233
  exit_status = result.exit_status
234
- stdout = JSON.pretty_generate(result.value)
234
+ # when we are using the shell method
235
+ # puts result.value.class # EasyNavProxy
236
+ # puts result.value # Hash looking object
237
+ stdout = JSON.pretty_generate(result.value.to_h)
235
238
  output = if exit_status == 0
236
239
  Style.green(stdout)
237
240
  else
@@ -3,6 +3,10 @@ module OpsWalrus
3
3
  end
4
4
 
5
5
  class RemoteInvocationError < Error
6
+ def initialize(msg, deserialized_invocation_error_hash)
7
+ super(msg)
8
+ @hash = deserialized_invocation_error_hash
9
+ end
6
10
  end
7
11
 
8
12
  class SymbolResolutionError < Error
@@ -178,7 +178,7 @@ module OpsWalrus
178
178
  # 1. Net::SSH::Disconnect < Net::SSH::Exception with message: "connection closed by remote host"
179
179
  # 2. Errno::ECONNRESET < SystemCallError with message: "Connection reset by peer"
180
180
  # 3. Errno::ECONNREFUSED < SystemCallError with message: "Connection refused - connect(2) for 192.168.56.10:22"
181
- rescue Net::SSH::Disconnect, Errno::ECONNRESET, Errno::ECONNREFUSED => e
181
+ rescue Net::SSH::Disconnect, Net::SSH::ConnectionTimeout, Errno::ECONNRESET, Errno::ECONNREFUSED => e
182
182
  # noop; we expect these while we're trying to reconnect
183
183
  rescue => e
184
184
  puts "#{e.class} < #{e.class.superclass}"
@@ -216,7 +216,16 @@ module OpsWalrus
216
216
  case retval
217
217
  when Hash
218
218
  if retval["type"] == 'Invocation::Error'
219
- raise RemoteInvocationError.new("Remote Invocation Error:\n #{retval["error_type"]}: #{retval["error"]}#{retval["backtrace"] && "\n Backtrace: #{retval['backtrace']}"}")
219
+ # this structure comes from OpsWalrus::Invocation::Error being serialized in App#print_script_result being called from App#run
220
+ # {
221
+ # type: "Invocation::Error",
222
+ # error_variant: self.class.name,
223
+ # error_class: value.class.name,
224
+ # error: value,
225
+ # backtrace: value.is_a?(Exception) ? value.backtrace.take(10).join("\n") : nil,
226
+ # }
227
+ # raise RemoteInvocationError.new("Remote Invocation Error:\n #{retval["error_class"]}: #{retval["error"]}#{retval["backtrace"] && "\n Backtrace: #{retval['backtrace']}"}")
228
+ raise RemoteInvocationError.new("Remote Invocation Error:\n #{retval["error_class"]}: #{retval["error"]}#{retval["backtrace"] && "\n Backtrace: #{retval['backtrace']}"}", retval)
220
229
  else
221
230
  retval.with_indifferent_access.easynav
222
231
  end
@@ -87,20 +87,20 @@ module OpsWalrus
87
87
  end
88
88
  rescue SSHKit::Command::Failed => e
89
89
  App.instance.error "Runtime error, command failed: #{e.message}"
90
- Invocation::Error.new(e)
90
+ Invocation::SshError.new(e)
91
91
  rescue Error => e
92
92
  # puts "OperationRunner#run - #{Time.now.strftime('%s%L')}"
93
93
  App.instance.error "Runtime error: Ops script crashed."
94
94
  App.instance.error e.message
95
95
  App.instance.error e.backtrace.take(10).join("\n")
96
- Invocation::Error.new(e)
96
+ Invocation::RuntimeError.new(e)
97
97
  rescue => e
98
98
  # puts "OperationRunner#run - #{Time.now.strftime('%s%L')}"
99
99
  App.instance.error "Unhandled runtime error: Ops script crashed."
100
100
  App.instance.error e.class
101
101
  App.instance.error e.message
102
102
  App.instance.error e.backtrace.take(10).join("\n")
103
- Invocation::Error.new(e)
103
+ Invocation::UnhandledError.new(e)
104
104
  end
105
105
 
106
106
  result
@@ -43,7 +43,8 @@ module OpsWalrus
43
43
  def serialize_error
44
44
  {
45
45
  type: "Invocation::Error",
46
- error_type: value.class.name,
46
+ error_variant: self.class.name,
47
+ error_class: value.class.name,
47
48
  error: value,
48
49
  backtrace: value.is_a?(Exception) ? value.backtrace.take(10).join("\n") : nil,
49
50
  }
@@ -52,6 +53,14 @@ module OpsWalrus
52
53
  true
53
54
  end
54
55
  end
56
+ class EarlyExitError < Error
57
+ end
58
+ class SshError < Error
59
+ end
60
+ class RuntimeError < Error
61
+ end
62
+ class UnhandledError < Error
63
+ end
55
64
  end
56
65
 
57
66
 
@@ -109,6 +118,8 @@ module OpsWalrus
109
118
  App.instance.error "[!] The host '#{host}' doesn't accept password authentication method."
110
119
  rescue Errno::EHOSTUNREACH => e
111
120
  App.instance.error "[!] The host '#{host}' is unreachable"
121
+ rescue RemoteInvocationError => e
122
+ results[host] = e
112
123
  rescue => e
113
124
  App.instance.error e.class
114
125
  App.instance.error e.message
@@ -178,6 +189,8 @@ module OpsWalrus
178
189
  App.instance.error "[!] The host '#{host}' doesn't accept password authentication method."
179
190
  rescue Errno::EHOSTUNREACH => e
180
191
  App.instance.error "[!] The host '#{host}' is unreachable"
192
+ rescue RemoteInvocationError => e
193
+ results[host] = e
181
194
  # rescue => e
182
195
  # App.instance.error "[!] Command failed:"
183
196
  # App.instance.error e.class
@@ -211,7 +224,7 @@ module OpsWalrus
211
224
  result = if exit_status == 0
212
225
  Invocation::Success.new(nil)
213
226
  else
214
- Invocation::Error.new(nil, exit_status)
227
+ Invocation::EarlyExitError.new(message, exit_status)
215
228
  end
216
229
  throw :exit_now, result
217
230
  end
@@ -1,6 +1,7 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext/hash'
3
3
  require 'active_support/core_ext/hash/indifferent_access'
4
+ require 'active_support/core_ext/string'
4
5
  require 'json'
5
6
  require 'pathname'
6
7
 
@@ -1,3 +1,3 @@
1
1
  module OpsWalrus
2
- VERSION = "1.0.95"
2
+ VERSION = "1.0.97"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opswalrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.95
4
+ version: 1.0.97
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Ellis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-17 00:00:00.000000000 Z
11
+ date: 2023-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport