opswalrus 1.0.53 → 1.0.55
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/_run_remote.ops +1 -2
- data/lib/opswalrus/bootstrap.sh +1 -1
- data/lib/opswalrus/bundler.rb +9 -1
- data/lib/opswalrus/host.rb +3 -4
- data/lib/opswalrus/invocation.rb +58 -0
- data/lib/opswalrus/ops_file.rb +7 -0
- data/lib/opswalrus/ops_file_script_dsl.rb +2 -1
- 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: 886446171ec646a644e8c99be6b4a5de56f502f54336d292168c9fe0e4411028
|
4
|
+
data.tar.gz: adc3c9c5ea70bb95361ba7797eac02b62a1e9a003ba6db5fcdd6e39faa7f5bf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecb4f917b14b27dc08435d09f44b242144bf3950bd613472d467927b8929cf5083825325f0b595b792647e005fc3e85b4702297cb722135b464bd11c5dc6c6bc
|
7
|
+
data.tar.gz: 447e67ec4a89559430ead09b63262a669998b03dfb0e862693440fbe94a7b6392ece30fdce7f72b755e49bd8fafe672bb430b56a2725cf1f6bad454b985655a7
|
data/Gemfile.lock
CHANGED
@@ -7,6 +7,5 @@ ssh in: :sequence 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
|
# run_ops(ops_command, ops_command_options = nil, command_arguments, in_bundle_root_dir: true, ops_prompt_for_sudo_password: false)
|
10
|
-
|
11
|
-
self._invoke_remote(params.ops_file, *params.operation_kv_args)
|
10
|
+
_invoke_remote(params.ops_file, *params.operation_kv_args)
|
12
11
|
end
|
data/lib/opswalrus/bootstrap.sh
CHANGED
@@ -27,7 +27,7 @@ if [ -x $RTX ]; then
|
|
27
27
|
|
28
28
|
# make sure the latest opswalrus gem is installed
|
29
29
|
# todo: figure out how to install this differently, so that test versions will work
|
30
|
-
|
30
|
+
gem install opswalrus
|
31
31
|
# $GEM_CMD install opswalrus
|
32
32
|
$RTX reshim
|
33
33
|
|
data/lib/opswalrus/bundler.rb
CHANGED
@@ -56,7 +56,11 @@ module OpsWalrus
|
|
56
56
|
# end
|
57
57
|
|
58
58
|
def update()
|
59
|
-
delete_pwd_bundle_directory
|
59
|
+
# delete_pwd_bundle_directory # this was causing problems when we do: ops run -r -b ... because a dynamic package reference was being
|
60
|
+
# downloaded to the bundle dir, and then update was being called afterward, which was blowing away
|
61
|
+
# the entire bundle dir, so when the bundle dir was copied to the remote host, the ops file being
|
62
|
+
# invoked was not present on the remote host, since it had never been copied over as a result
|
63
|
+
# of the bundle dir being blown away after the dynamic package reference had been downloaded
|
60
64
|
ensure_pwd_bundle_directory_exists
|
61
65
|
|
62
66
|
package_yaml_files = pwd.glob("./**/package.yaml") - pwd.glob("./**/#{BUNDLE_DIR}/**/package.yaml")
|
@@ -204,6 +208,8 @@ module OpsWalrus
|
|
204
208
|
|
205
209
|
destination_package_path ||= dynamic_package_path_for_git_package(package_url, version)
|
206
210
|
|
211
|
+
App.instance.debug "Download git package #{package_url} version #{version.inspect} to #{destination_package_path}"
|
212
|
+
|
207
213
|
return destination_package_path if destination_package_path.exist?
|
208
214
|
|
209
215
|
if version
|
@@ -212,6 +218,8 @@ module OpsWalrus
|
|
212
218
|
::Git.clone(package_url, destination_package_path, config: ['submodule.recurse=true'])
|
213
219
|
end
|
214
220
|
|
221
|
+
App.instance.debug "Downloaded git package #{package_url} version #{version.inspect} to #{destination_package_path}"
|
222
|
+
|
215
223
|
destination_package_path
|
216
224
|
end
|
217
225
|
|
data/lib/opswalrus/host.rb
CHANGED
@@ -82,10 +82,9 @@ module OpsWalrus
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def _invoke_remote(ops_file, *args, **kwargs)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
invocation_context._invoke(*args, **kwargs)
|
85
|
+
App.instance.debug "Remove invoke #{ops_file.relative_path_to_app_pwd} on host `#{to_s}` with args:\n #{args.inspect}\nkwargs:\n #{kwargs.inspect}"
|
86
|
+
|
87
|
+
RemoteInvocation.new(self, ops_file, ops_prompt_for_sudo_password: !!ssh_password).invoke(*args, **kwargs)
|
89
88
|
end
|
90
89
|
|
91
90
|
# returns [stdout, stderr, exit_status]
|
data/lib/opswalrus/invocation.rb
CHANGED
@@ -196,4 +196,62 @@ module OpsWalrus
|
|
196
196
|
|
197
197
|
end
|
198
198
|
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
class RemoteInvocation
|
204
|
+
def initialize(host_proxy, ops_file, ops_prompt_for_sudo_password: nil)
|
205
|
+
@host_proxy = host_proxy
|
206
|
+
@ops_file = ops_file
|
207
|
+
@ops_prompt_for_sudo_password = ops_prompt_for_sudo_password
|
208
|
+
end
|
209
|
+
|
210
|
+
def invoke(*args, **kwargs)
|
211
|
+
# when there are args or kwargs, then the method invocation represents an attempt to run an OpsFile on a remote host,
|
212
|
+
# so we want to build up a command and send it to the remote host via HostDSL#run_ops
|
213
|
+
remote_run_command_args = @ops_file.relative_path_to_app_pwd.to_s
|
214
|
+
|
215
|
+
unless args.empty?
|
216
|
+
remote_run_command_args << " "
|
217
|
+
remote_run_command_args << args.join(" ")
|
218
|
+
end
|
219
|
+
|
220
|
+
begin
|
221
|
+
json = JSON.dump(kwargs) unless kwargs.empty?
|
222
|
+
if json
|
223
|
+
# write the kwargs to a tempfile
|
224
|
+
json_kwargs_tempfile = Tempfile.create('ops_invoke_kwargs')
|
225
|
+
json_kwargs_tempfile.write(json)
|
226
|
+
json_kwargs_tempfile.close() # we want to close the file without unlinking so that we can copy it to the remote host before deleting it
|
227
|
+
|
228
|
+
# upload the kwargs file to the remote host
|
229
|
+
json_kwargs_tempfile_path = json_kwargs_tempfile.path.to_pathname
|
230
|
+
remote_json_kwargs_tempfile_basename = json_kwargs_tempfile_path.basename
|
231
|
+
@host_proxy.upload(json_kwargs_tempfile_path, remote_json_kwargs_tempfile_basename)
|
232
|
+
end
|
233
|
+
|
234
|
+
# invoke the ops command on the remote host to run the specified ops script on the remote host
|
235
|
+
ops_command_options = ""
|
236
|
+
ops_command_options << "--pass" if @ops_prompt_for_sudo_password
|
237
|
+
ops_command_options << " --params #{remote_json_kwargs_tempfile_basename}" if remote_json_kwargs_tempfile_basename
|
238
|
+
retval = if ops_command_options.empty?
|
239
|
+
@host_proxy.run_ops(:run, remote_run_command_args, ops_prompt_for_sudo_password: @ops_prompt_for_sudo_password)
|
240
|
+
else
|
241
|
+
@host_proxy.run_ops(:run, ops_command_options, remote_run_command_args, ops_prompt_for_sudo_password: @ops_prompt_for_sudo_password)
|
242
|
+
end
|
243
|
+
|
244
|
+
retval
|
245
|
+
ensure
|
246
|
+
if json_kwargs_tempfile
|
247
|
+
json_kwargs_tempfile.close rescue nil
|
248
|
+
File.unlink(json_kwargs_tempfile) rescue nil
|
249
|
+
end
|
250
|
+
# todo: make sure this cleanup is present
|
251
|
+
if remote_json_kwargs_tempfile_basename
|
252
|
+
@host_proxy.execute(:rm, "-f", remote_json_kwargs_tempfile_basename)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
199
257
|
end
|
data/lib/opswalrus/ops_file.rb
CHANGED
@@ -233,6 +233,13 @@ module OpsWalrus
|
|
233
233
|
# end
|
234
234
|
# end
|
235
235
|
|
236
|
+
# if ops_file_path is /home/david/sync/projects/ops/davidinfra/opswalrus_bundle/pkg_https---github.com-opswalrus-core_version_/file/exists.ops
|
237
|
+
# and the @app.pwd is /home/david/sync/projects/ops/davidinfra
|
238
|
+
# then this returns opswalrus_bundle/pkg_https---github.com-opswalrus-core_version_/file/exists.ops
|
239
|
+
def relative_path_to_app_pwd
|
240
|
+
@ops_file_path.relative_path_from(@app.pwd)
|
241
|
+
end
|
242
|
+
|
236
243
|
# "/home/david/sync/projects/ops/ops/core/host/info.ops" => "/home/david/sync/projects/ops/ops/core/host"
|
237
244
|
def dirname
|
238
245
|
@ops_file_path.dirname
|
@@ -48,6 +48,7 @@ module OpsWalrus
|
|
48
48
|
|
49
49
|
|
50
50
|
module OpsFileScriptDSL
|
51
|
+
# we run the block in the context of the host proxy object, s.t. `self` within the block evaluates to the host proxy object
|
51
52
|
def ssh_noprep(*args, **kwargs, &block)
|
52
53
|
runtime_env = @runtime_env
|
53
54
|
|
@@ -112,6 +113,7 @@ module OpsWalrus
|
|
112
113
|
results
|
113
114
|
end # def ssh
|
114
115
|
|
116
|
+
# we run the block in the context of the host proxy object, s.t. `self` within the block evaluates to the host proxy object
|
115
117
|
def ssh(*args, **kwargs, &block)
|
116
118
|
runtime_env = @runtime_env
|
117
119
|
|
@@ -122,7 +124,6 @@ module OpsWalrus
|
|
122
124
|
|
123
125
|
results_lock = Thread::Mutex.new
|
124
126
|
results = {}
|
125
|
-
# bootstrap_shell_script = BootstrapLinuxHostShellScript
|
126
127
|
# on sshkit_hosts do |sshkit_host|
|
127
128
|
SSHKit::Coordinator.new(sshkit_hosts).each(in: kwargs[:in] || :parallel) do |sshkit_host|
|
128
129
|
# in this context, self is an instance of one of the subclasses of SSHKit::Backend::Abstract, e.g. SSHKit::Backend::Netssh
|
data/lib/opswalrus/version.rb
CHANGED