opswalrus 1.0.38 → 1.0.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/opswalrus/host.rb +14 -1
- data/lib/opswalrus/ops_file_script.rb +11 -2
- data/lib/opswalrus/ops_file_script_dsl.rb +11 -19
- data/lib/opswalrus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 413ca26075395f1e533a83af05aae8522f66fb91b96de13d8932f5856053222d
|
4
|
+
data.tar.gz: cf99aa4a8e71dba2a36129ed3ca2cb51b603d106fd240a0d1d39784e53e6806c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ba6764a3018cc959a075b9616d14116ae28c565a53f557864fb6d9ce1b922d75439e79b1563fedd7a4a5cd2a17277243ee8b1d47d5f82c30f6898d08b4088bc
|
7
|
+
data.tar.gz: f8985876bbc10366839f871818a50d4578728d63f5234ec13479a54801b5771fc8f5e7f9a5c3328c58a508997cd5e12b581b45de1aae759e1a6a71dedeb33118
|
data/Gemfile.lock
CHANGED
data/lib/opswalrus/host.rb
CHANGED
@@ -224,7 +224,15 @@ module OpsWalrus
|
|
224
224
|
end
|
225
225
|
|
226
226
|
def desc(msg)
|
227
|
-
puts msg.mustache(
|
227
|
+
puts msg.mustache(2) # we use two here, because one stack frame accounts for the call from the ops script into HostProxy#desc
|
228
|
+
end
|
229
|
+
|
230
|
+
def env(*args, **kwargs)
|
231
|
+
@ops_file_script.env(*args, **kwargs)
|
232
|
+
end
|
233
|
+
|
234
|
+
def params(*args, **kwargs)
|
235
|
+
@ops_file_script.params(*args, **kwargs)
|
228
236
|
end
|
229
237
|
|
230
238
|
def host_prop(name)
|
@@ -360,6 +368,10 @@ module OpsWalrus
|
|
360
368
|
@runtime_env = runtime_env
|
361
369
|
end
|
362
370
|
|
371
|
+
def set_ops_file_script(ops_file_script)
|
372
|
+
@ops_file_script = ops_file_script
|
373
|
+
end
|
374
|
+
|
363
375
|
def set_ssh_session_connection(sshkit_backend)
|
364
376
|
@sshkit_backend = sshkit_backend
|
365
377
|
end
|
@@ -370,6 +382,7 @@ module OpsWalrus
|
|
370
382
|
|
371
383
|
def clear_ssh_session
|
372
384
|
@runtime_env = nil
|
385
|
+
ops_file_script = nil
|
373
386
|
@sshkit_backend = nil
|
374
387
|
@tmp_bundle_root_dir = nil
|
375
388
|
@tmp_ssh_key_files.each {|tmpfile| tmpfile.close() rescue nil; File.unlink(tmpfile) rescue nil }
|
@@ -141,12 +141,11 @@ module OpsWalrus
|
|
141
141
|
def _invoke(runtime_env, hashlike_params)
|
142
142
|
@runtime_env = runtime_env
|
143
143
|
@params = InvocationParams.new(hashlike_params)
|
144
|
-
params = @params
|
145
144
|
#{ruby_script}
|
146
145
|
end
|
147
146
|
INVOKE_METHOD
|
148
147
|
|
149
|
-
invoke_method_line_count_prior_to_ruby_script_from_ops_file =
|
148
|
+
invoke_method_line_count_prior_to_ruby_script_from_ops_file = 3
|
150
149
|
klass.module_eval(invoke_method_definition, ops_file.ops_file_path.to_s, ops_file.script_line_offset - invoke_method_line_count_prior_to_ruby_script_from_ops_file)
|
151
150
|
|
152
151
|
klass
|
@@ -161,6 +160,7 @@ module OpsWalrus
|
|
161
160
|
@ops_file = ops_file
|
162
161
|
@script = ruby_script
|
163
162
|
@runtime_env = nil # this is set at the very first line of #_invoke
|
163
|
+
@params = nil # this is set at the very first line of #_invoke
|
164
164
|
end
|
165
165
|
|
166
166
|
def backend
|
@@ -184,6 +184,15 @@ module OpsWalrus
|
|
184
184
|
raise "Not implemented in base class."
|
185
185
|
end
|
186
186
|
|
187
|
+
def params(*keys, default: nil)
|
188
|
+
keys = keys.map(&:to_s)
|
189
|
+
if keys.empty?
|
190
|
+
@params
|
191
|
+
else
|
192
|
+
@params.dig(*keys) || default
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
187
196
|
def to_s
|
188
197
|
@script
|
189
198
|
end
|
@@ -107,7 +107,7 @@ module OpsWalrus
|
|
107
107
|
hosts = inventory(*args, **kwargs).map {|host| host_proxy_class.new(runtime_env, host) }
|
108
108
|
sshkit_hosts = hosts.map(&:sshkit_host)
|
109
109
|
sshkit_host_to_ops_host_map = sshkit_hosts.zip(hosts).to_h
|
110
|
-
local_host = self
|
110
|
+
ops_file_script = local_host = self
|
111
111
|
# bootstrap_shell_script = BootstrapLinuxHostShellScript
|
112
112
|
# on sshkit_hosts do |sshkit_host|
|
113
113
|
SSHKit::Coordinator.new(sshkit_hosts).each(in: kwargs[:in] || :parallel) do |sshkit_host|
|
@@ -116,6 +116,7 @@ module OpsWalrus
|
|
116
116
|
|
117
117
|
begin
|
118
118
|
host.set_runtime_env(runtime_env)
|
119
|
+
host.set_ops_file_script(ops_file_script)
|
119
120
|
host.set_ssh_session_connection(self) # self is an instance of one of the subclasses of SSHKit::Backend::Abstract, e.g. SSHKit::Backend::Netssh
|
120
121
|
|
121
122
|
host._bootstrap_host
|
@@ -172,15 +173,6 @@ module OpsWalrus
|
|
172
173
|
throw :exit_now, result
|
173
174
|
end
|
174
175
|
|
175
|
-
def env(*keys)
|
176
|
-
keys = keys.map(&:to_s)
|
177
|
-
if keys.empty?
|
178
|
-
@runtime_env.env
|
179
|
-
else
|
180
|
-
@runtime_env.env.dig(*keys)
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
176
|
# currently, import may only be used to import a package that is referenced in the script's package file
|
185
177
|
# I may decide to extend this to work with dynamic package references
|
186
178
|
#
|
@@ -198,19 +190,19 @@ module OpsWalrus
|
|
198
190
|
# invocation_context._invoke(*args, **kwargs)
|
199
191
|
end
|
200
192
|
|
201
|
-
# def params(*keys, default: nil)
|
202
|
-
# keys = keys.map(&:to_s)
|
203
|
-
# if keys.empty?
|
204
|
-
# @params
|
205
|
-
# else
|
206
|
-
# @params.dig(*keys) || default
|
207
|
-
# end
|
208
|
-
# end
|
209
|
-
|
210
193
|
def desc(msg)
|
211
194
|
puts msg.mustache(1)
|
212
195
|
end
|
213
196
|
|
197
|
+
def env(*keys)
|
198
|
+
keys = keys.map(&:to_s)
|
199
|
+
if keys.empty?
|
200
|
+
@runtime_env.env
|
201
|
+
else
|
202
|
+
@runtime_env.env.dig(*keys)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
214
206
|
# runs the given command
|
215
207
|
# returns the stdout from the command
|
216
208
|
def sh(desc_or_cmd = nil, cmd = nil, input: nil, &block)
|
data/lib/opswalrus/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.39
|
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-09-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|