opswalrus 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/opswalrus/app.rb +12 -0
- data/lib/opswalrus/cli.rb +5 -0
- data/lib/opswalrus/host.rb +12 -5
- data/lib/opswalrus/ops_file_script.rb +4 -2
- data/lib/opswalrus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4d06b1bc87888397e4509eda913a1a5ad0cf4f069762852282de9c1cd7c6a0
|
4
|
+
data.tar.gz: 605d4b7e09d3fe47b2fa5106d5cd27e8255ba5265dff1bcfe8fbda3fb380195d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cce83e3128b0d19d7ccec3d0fe85411d19959229fc8cd3ad9fdf47b40c739e598f3dd2020078492361df9d309b15e0c82824901ff2511b434adea09c9484d246
|
7
|
+
data.tar.gz: 7bc58a62f322c543e2aa57b5a75611d4984c3b72454c4ac52fbd91bfa074efde217fa8355bfc38718d13b0ac839fbe13c8c567307e0c1516e3067cea351f4594
|
data/lib/opswalrus/app.rb
CHANGED
@@ -64,6 +64,14 @@ module OpsWalrus
|
|
64
64
|
"" # return empty string because we won't want anyone accidentally printing or inspecting @sudo_password
|
65
65
|
end
|
66
66
|
|
67
|
+
def emit_json_output!
|
68
|
+
@emit_json_output = true
|
69
|
+
end
|
70
|
+
|
71
|
+
def emit_json_output?
|
72
|
+
@emit_json_output
|
73
|
+
end
|
74
|
+
|
67
75
|
def set_local_hostname(hostname)
|
68
76
|
hostname = hostname.strip
|
69
77
|
@local_hostname = hostname.empty? ? "localhost" : hostname
|
@@ -186,6 +194,10 @@ module OpsWalrus
|
|
186
194
|
puts JSON.pretty_generate(result.value)
|
187
195
|
end
|
188
196
|
|
197
|
+
if emit_json_output?
|
198
|
+
puts JSON.pretty_generate(result.value)
|
199
|
+
end
|
200
|
+
|
189
201
|
exit_status
|
190
202
|
ensure
|
191
203
|
FileUtils.remove_entry(tmp_dir) if tmp_dir
|
data/lib/opswalrus/cli.rb
CHANGED
@@ -53,6 +53,7 @@ module OpsWalrus
|
|
53
53
|
c.flag [:u, :user], desc: "Specify the user that the operation will run as"
|
54
54
|
c.switch :pass, desc: "Prompt for a sudo password"
|
55
55
|
c.flag [:p, :params], desc: "JSON string that represents the input parameters for the operation. The JSON string must conform to the params schema for the operation."
|
56
|
+
c.switch :json, desc: "Emit JSON output"
|
56
57
|
|
57
58
|
c.action do |global_options, options, args|
|
58
59
|
hosts = global_options[:hosts] || []
|
@@ -80,6 +81,10 @@ module OpsWalrus
|
|
80
81
|
$app.prompt_sudo_password
|
81
82
|
end
|
82
83
|
|
84
|
+
if options[:json]
|
85
|
+
$app.emit_json_output!
|
86
|
+
end
|
87
|
+
|
83
88
|
# puts "verbose"
|
84
89
|
# puts verbose.inspect
|
85
90
|
# puts "user"
|
data/lib/opswalrus/host.rb
CHANGED
@@ -86,19 +86,26 @@ module OpsWalrus
|
|
86
86
|
# so we want to build up a command and send it to the remote host via HostDSL#run_ops
|
87
87
|
@method_chain.unshift(Bundler::BUNDLE_DIR) if @is_invocation_a_call_to_package_in_bundle_dir
|
88
88
|
|
89
|
-
|
90
|
-
# remote_run_command_args << path_to_ops_file_basename
|
89
|
+
remote_run_command_args = "--json"
|
91
90
|
|
92
|
-
remote_run_command_args
|
91
|
+
remote_run_command_args << " "
|
92
|
+
remote_run_command_args << @method_chain.join(" ")
|
93
93
|
|
94
94
|
unless args.empty?
|
95
95
|
remote_run_command_args << " "
|
96
96
|
remote_run_command_args << args.join(" ")
|
97
97
|
end
|
98
98
|
|
99
|
-
unless
|
99
|
+
unless kwargs.empty?
|
100
100
|
remote_run_command_args << " "
|
101
|
-
remote_run_command_args <<
|
101
|
+
remote_run_command_args << kwargs.map do |k, v|
|
102
|
+
case v
|
103
|
+
when Array
|
104
|
+
v.map {|v_element| "#{k}:#{v_element}" }
|
105
|
+
else
|
106
|
+
"#{k}:#{v}"
|
107
|
+
end
|
108
|
+
end.join(" ")
|
102
109
|
end
|
103
110
|
|
104
111
|
@host_proxy.run_ops(:run, remote_run_command_args)
|
@@ -148,9 +148,11 @@ module OpsWalrus
|
|
148
148
|
# we run the block in the context of the host, s.t. `self` within the block evaluates to `host`
|
149
149
|
retval = host.instance_exec(local_host, &block) # host is passed as the argument to the block
|
150
150
|
|
151
|
+
puts retval.inspect
|
152
|
+
|
151
153
|
# cleanup
|
152
|
-
if
|
153
|
-
host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip",
|
154
|
+
if tmp_bundle_root_dir =~ /tmp/ # sanity check the temp path before we blow away something we don't intend
|
155
|
+
host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip", tmp_bundle_root_dir)
|
154
156
|
else
|
155
157
|
host.execute(:rm, "-rf", "tmpopsbootstrap.sh", "tmpops.zip")
|
156
158
|
end
|
data/lib/opswalrus/version.rb
CHANGED