opswalrus 1.0.68 → 1.0.69
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/Gemfile.lock +1 -1
- data/lib/opswalrus/app.rb +2 -2
- data/lib/opswalrus/hosts_file.rb +11 -2
- data/lib/opswalrus/inventory.rb +16 -3
- data/lib/opswalrus/ops_file_script_dsl.rb +5 -1
- data/lib/opswalrus/patches.rb +1 -0
- data/lib/opswalrus/runtime_environment.rb +5 -2
- 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: bf8bbbf6ab94da7f777b80b69dafef9ff37e490ca47542f5468a133f0ab3ad6a
|
|
4
|
+
data.tar.gz: 93d2e3403290b71946260ccc022e52ebc32a8daf94f2bb9586364948470258c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 669268a317cb43a8b970ac8fadd7578e76b05e34a3bcb0c22c83846f421aca4785644b44738616afe8461afb4d484cd2d1bc9c0dee202b15f13ee2597e3f45c9
|
|
7
|
+
data.tar.gz: f7cc3a65e679bc4b547f8c14506de8cd0dc3ca049c9e09fa3ff4c2b20d35ba95e2d82fef38271ab3dfdc599d79e2beea433e3ab2d572b3df9bd3500752e801a8
|
data/Gemfile.lock
CHANGED
data/lib/opswalrus/app.rb
CHANGED
|
@@ -449,7 +449,7 @@ module OpsWalrus
|
|
|
449
449
|
end
|
|
450
450
|
|
|
451
451
|
def report_inventory(host_references, tags: nil)
|
|
452
|
-
selected_hosts = inventory(tags, host_references)
|
|
452
|
+
selected_hosts = inventory(tags, host_references).hosts
|
|
453
453
|
|
|
454
454
|
selected_hosts.each do |host|
|
|
455
455
|
puts host.summary(verbose?)
|
|
@@ -464,7 +464,7 @@ module OpsWalrus
|
|
|
464
464
|
|
|
465
465
|
host_references = [HostsFile::DEFAULT_FILE_NAME] if (host_references.nil? || host_references.empty?) && File.exist?(HostsFile::DEFAULT_FILE_NAME)
|
|
466
466
|
|
|
467
|
-
Inventory.new(host_references, tags)
|
|
467
|
+
Inventory.new(host_references, tags)
|
|
468
468
|
end
|
|
469
469
|
|
|
470
470
|
def edit_inventory(file_path)
|
data/lib/opswalrus/hosts_file.rb
CHANGED
|
@@ -54,7 +54,7 @@ module OpsWalrus
|
|
|
54
54
|
# "192.168.56.10"=>{"tags"=>["web", "vagrant"]}
|
|
55
55
|
# }
|
|
56
56
|
@yaml.map do |host_ref, host_attrs|
|
|
57
|
-
next if ['default', 'defaults', '
|
|
57
|
+
next if ['default', 'defaults', 'env', 'ids', 'secrets'].include?(host_ref)
|
|
58
58
|
|
|
59
59
|
host_params = host_attrs.is_a?(Hash) ? host_attrs : {}
|
|
60
60
|
|
|
@@ -122,6 +122,11 @@ module OpsWalrus
|
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
+
# returns a Hash object that may have nested structures
|
|
126
|
+
def env
|
|
127
|
+
@env ||= (@yaml["env"] || {})
|
|
128
|
+
end
|
|
129
|
+
|
|
125
130
|
def tags(host)
|
|
126
131
|
host_attrs = @yaml[host]
|
|
127
132
|
|
|
@@ -148,10 +153,14 @@ module OpsWalrus
|
|
|
148
153
|
yaml.sub(/^---\s*/,"") # omit the leading line: ---\n
|
|
149
154
|
end
|
|
150
155
|
|
|
156
|
+
def has_secret?(secret_name)
|
|
157
|
+
secrets[secret_name]
|
|
158
|
+
end
|
|
159
|
+
|
|
151
160
|
# returns the decrypted value referenced by secret_name
|
|
152
161
|
def read_secret(secret_name)
|
|
153
162
|
secret = secrets[secret_name]
|
|
154
|
-
secret.decrypt(@cipher)
|
|
163
|
+
secret.decrypt(@cipher) if secret
|
|
155
164
|
end
|
|
156
165
|
|
|
157
166
|
def encrypt_secrets!()
|
data/lib/opswalrus/inventory.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
1
|
+
require 'active_support/core_ext/hash'
|
|
2
|
+
require 'pathname'
|
|
3
|
+
require 'tty-editor'
|
|
4
|
+
require 'yaml'
|
|
4
5
|
|
|
5
6
|
module OpsWalrus
|
|
6
7
|
class Inventory
|
|
@@ -11,6 +12,18 @@ module OpsWalrus
|
|
|
11
12
|
@tags = tags
|
|
12
13
|
end
|
|
13
14
|
|
|
15
|
+
def env
|
|
16
|
+
@env ||= hosts_files.reduce({}) {|memo, hosts_file| memo.deep_merge(hosts_file.env) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def read_secret(secret_name)
|
|
20
|
+
hosts_files.find {|hosts_file| hosts_file.has_secret?(secret_name) }&.read_secret(secret_name)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def hosts_files
|
|
24
|
+
@hosts_files ||= @host_references.select {|ref| File.exist?(ref) }.map {|file_path| HostsFile.new(file_path) }
|
|
25
|
+
end
|
|
26
|
+
|
|
14
27
|
def hosts()
|
|
15
28
|
hosts_files, host_strings = @host_references.partition {|ref| File.exist?(ref) }
|
|
16
29
|
inventory_file_hosts = hosts_files.
|
|
@@ -192,7 +192,7 @@ module OpsWalrus
|
|
|
192
192
|
kwargs = kwargs.transform_keys(&:to_s)
|
|
193
193
|
tags.concat(kwargs["tags"]) if kwargs["tags"]
|
|
194
194
|
|
|
195
|
-
@runtime_env.app.inventory(tags)
|
|
195
|
+
@runtime_env.app.inventory(tags).hosts
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
def exit(exit_status, message = nil)
|
|
@@ -244,6 +244,10 @@ module OpsWalrus
|
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|
|
247
|
+
def read_secret(secret_name)
|
|
248
|
+
@runtime_env.read_secret(secret_name)
|
|
249
|
+
end
|
|
250
|
+
|
|
247
251
|
# runs the given command
|
|
248
252
|
# returns the stdout from the command
|
|
249
253
|
def sh(desc_or_cmd = nil, cmd = nil, input: nil, &block)
|
data/lib/opswalrus/patches.rb
CHANGED
|
@@ -240,8 +240,7 @@ module OpsWalrus
|
|
|
240
240
|
|
|
241
241
|
def initialize(app)
|
|
242
242
|
@app = app
|
|
243
|
-
|
|
244
|
-
@env = ENV.to_h.with_indifferent_access.easynav
|
|
243
|
+
@env = @app.inventory.env.deep_merge(ENV.to_h).with_indifferent_access.easynav
|
|
245
244
|
@bundle_load_path = LoadPath.new(self, @app.bundle_dir)
|
|
246
245
|
@app_load_path = LoadPath.new(self, @app.pwd)
|
|
247
246
|
|
|
@@ -262,6 +261,10 @@ module OpsWalrus
|
|
|
262
261
|
configure_sshkit
|
|
263
262
|
end
|
|
264
263
|
|
|
264
|
+
def read_secret(secret_name)
|
|
265
|
+
@app.inventory.read_secret(secret_name.to_s)
|
|
266
|
+
end
|
|
267
|
+
|
|
265
268
|
# input_mapping : Hash[ String | Regex => String ]
|
|
266
269
|
# sudo_password : String
|
|
267
270
|
def handle_input(input_mapping, sudo_password: nil, ops_sudo_password: nil, inherit_existing_mappings: true, &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.69
|
|
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
|
+
date: 2023-10-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|