opswalrus 1.0.68 → 1.0.70
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/app.rb +2 -2
- data/lib/opswalrus/hosts_file.rb +12 -3
- 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: 3be927f8a6e3ff21022fce2524d475897bdb910c4c7929dae53923b418fa74b0
|
4
|
+
data.tar.gz: 1ba0e6af4e70a2509db80f306f2f4b9e7ab299623ec86e931c9200d30e69142a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c3955d601910ecb51c000a2d875a9012827878c0b4bf140b2c8d35b4ca80c68a5702140fb66148303d5fc4d3367456a3ecccd3849b5fc2629fa07d1709a62d2
|
7
|
+
data.tar.gz: b0386db476b91c429c12bce0c15d690ca35e7cb2701fe38c4b0fdaa25ed931f1bc0c19e7067f72a52d40679b541da256699fd893bea5e8ef355757b06c66e6e3
|
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
|
|
@@ -144,14 +149,18 @@ module OpsWalrus
|
|
144
149
|
hash["secrets"] = secrets
|
145
150
|
hash["ids"] = ids
|
146
151
|
|
147
|
-
yaml = Psych.safe_dump(hash, permitted_classes: [SecretRef, Secret, PublicKey])
|
152
|
+
yaml = Psych.safe_dump(hash, permitted_classes: [SecretRef, Secret, PublicKey], line_width: 500)
|
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.70
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|