openbolt 5.0.0.pre.rc2 → 5.1.0
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/Puppetfile +18 -12
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +5 -3
- data/bolt-modules/boltlib/lib/puppet/functions/download_file.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +2 -0
- data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_command.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_container.rb +2 -2
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/set_resources.rb +2 -2
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -0
- data/bolt-modules/boltlib/lib/puppet/functions/wait.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +1 -0
- data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +1 -0
- data/lib/bolt/analytics.rb +1 -1
- data/lib/bolt/application.rb +17 -22
- data/lib/bolt/applicator.rb +4 -0
- data/lib/bolt/bolt_option_parser.rb +10 -8
- data/lib/bolt/cli.rb +7 -6
- data/lib/bolt/config/options.rb +59 -67
- data/lib/bolt/config/transport/base.rb +1 -0
- data/lib/bolt/config/transport/options.rb +59 -59
- data/lib/bolt/config.rb +8 -6
- data/lib/bolt/executor.rb +9 -24
- data/lib/bolt/fiber_executor.rb +3 -1
- data/lib/bolt/inventory/group.rb +3 -0
- data/lib/bolt/inventory/inventory.rb +2 -0
- data/lib/bolt/inventory/options.rb +7 -7
- data/lib/bolt/inventory/target.rb +3 -2
- data/lib/bolt/inventory.rb +1 -0
- data/lib/bolt/logger.rb +2 -0
- data/lib/bolt/module.rb +1 -0
- data/lib/bolt/module_installer/puppetfile.rb +4 -4
- data/lib/bolt/module_installer/resolver.rb +2 -2
- data/lib/bolt/module_installer/specs/forge_spec.rb +4 -4
- data/lib/bolt/module_installer/specs/git_spec.rb +6 -6
- data/lib/bolt/module_installer/specs/id/gitclone.rb +1 -0
- data/lib/bolt/module_installer/specs/id/github.rb +2 -1
- data/lib/bolt/module_installer/specs/id/gitlab.rb +2 -1
- data/lib/bolt/module_installer.rb +3 -1
- data/lib/bolt/outputter/human.rb +9 -4
- data/lib/bolt/outputter/rainbow.rb +1 -0
- data/lib/bolt/pal/yaml_plan/parameter.rb +2 -2
- data/lib/bolt/pal/yaml_plan/step/resources.rb +1 -1
- data/lib/bolt/pal.rb +4 -1
- data/lib/bolt/plan_creator.rb +5 -4
- data/lib/bolt/plugin/cache.rb +2 -0
- data/lib/bolt/plugin/module.rb +7 -0
- data/lib/bolt/plugin/puppet_connect_data.rb +1 -0
- data/lib/bolt/plugin/task.rb +3 -0
- data/lib/bolt/plugin.rb +4 -0
- data/lib/bolt/project.rb +3 -3
- data/lib/bolt/project_manager/config_migrator.rb +3 -3
- data/lib/bolt/project_manager/inventory_migrator.rb +1 -1
- data/lib/bolt/project_manager/module_migrator.rb +7 -6
- data/lib/bolt/project_manager.rb +11 -11
- data/lib/bolt/puppetdb/config.rb +4 -0
- data/lib/bolt/puppetdb/instance.rb +1 -0
- data/lib/bolt/rerun.rb +1 -0
- data/lib/bolt/resource_instance.rb +1 -1
- data/lib/bolt/result.rb +2 -1
- data/lib/bolt/shell/bash.rb +2 -1
- data/lib/bolt/shell/powershell.rb +4 -3
- data/lib/bolt/shell.rb +1 -1
- data/lib/bolt/task/run.rb +1 -0
- data/lib/bolt/task.rb +3 -0
- data/lib/bolt/transport/docker/connection.rb +2 -0
- data/lib/bolt/transport/jail/connection.rb +2 -0
- data/lib/bolt/transport/lxd/connection.rb +2 -0
- data/lib/bolt/transport/lxd.rb +1 -1
- data/lib/bolt/transport/podman/connection.rb +2 -0
- data/lib/bolt/transport/remote.rb +1 -0
- data/lib/bolt/transport/ssh/connection.rb +1 -1
- data/lib/bolt/transport/winrm/connection.rb +4 -3
- data/lib/bolt/util/format.rb +1 -0
- data/lib/bolt/util.rb +7 -4
- data/lib/bolt/validator.rb +1 -1
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_spec/plans/action_stubs.rb +5 -0
- data/lib/bolt_spec/plans/mock_executor.rb +2 -4
- data/libexec/apply_catalog.rb +2 -1
- data/libexec/custom_facts.rb +1 -1
- data/libexec/query_resources.rb +1 -1
- metadata +34 -51
- data/lib/bolt/config/transport/orch.rb +0 -41
- data/lib/bolt/transport/orch/connection.rb +0 -111
- data/lib/bolt/transport/orch.rb +0 -271
data/lib/bolt/validator.rb
CHANGED
|
@@ -172,7 +172,7 @@ module Bolt
|
|
|
172
172
|
private def plugin_reference?(value, plugin_supported)
|
|
173
173
|
if value.is_a?(Hash) && value.key?('_plugin')
|
|
174
174
|
unless plugin_supported
|
|
175
|
-
@errors << "Value at '#{path}' is a plugin reference, which is unsupported at "\
|
|
175
|
+
@errors << "Value at '#{path}' is a plugin reference, which is unsupported at " \
|
|
176
176
|
"this location"
|
|
177
177
|
end
|
|
178
178
|
|
data/lib/bolt/version.rb
CHANGED
|
@@ -103,6 +103,7 @@ module BoltSpec
|
|
|
103
103
|
unless result_set.is_a?(Bolt::ResultSet)
|
|
104
104
|
raise "Return block for #{object} did not return a Bolt::ResultSet"
|
|
105
105
|
end
|
|
106
|
+
|
|
106
107
|
result_set
|
|
107
108
|
end
|
|
108
109
|
|
|
@@ -110,6 +111,7 @@ module BoltSpec
|
|
|
110
111
|
unless plan_result.is_a?(Bolt::PlanResult)
|
|
111
112
|
raise "Return block for #{plan_clj.closure_name} did not return a Bolt::PlanResult"
|
|
112
113
|
end
|
|
114
|
+
|
|
113
115
|
plan_result
|
|
114
116
|
end
|
|
115
117
|
|
|
@@ -144,6 +146,7 @@ module BoltSpec
|
|
|
144
146
|
|
|
145
147
|
def return(&block)
|
|
146
148
|
raise "Cannot set return values and return block." if @data_set
|
|
149
|
+
|
|
147
150
|
@return_block = block
|
|
148
151
|
self
|
|
149
152
|
end
|
|
@@ -153,12 +156,14 @@ module BoltSpec
|
|
|
153
156
|
def return_for_targets(data)
|
|
154
157
|
data.each_with_object(@data) do |(target, result), hsh|
|
|
155
158
|
raise "Mocked results must be hashes: #{target}: #{result}" unless result.is_a? Hash
|
|
159
|
+
|
|
156
160
|
# set the inventory from the BoltSpec::Plans, otherwise if we try to convert
|
|
157
161
|
# this target to a string, it will fail to string conversion because the
|
|
158
162
|
# inventory is nil
|
|
159
163
|
hsh[target] = result_for(Bolt::Target.new(target, @inventory), **Bolt::Util.walk_keys(result, &:to_sym))
|
|
160
164
|
end
|
|
161
165
|
raise "Cannot set return values and return block." if @return_block
|
|
166
|
+
|
|
162
167
|
@data_set = true
|
|
163
168
|
self
|
|
164
169
|
end
|
|
@@ -251,11 +251,13 @@ module BoltSpec
|
|
|
251
251
|
|
|
252
252
|
def queue_execute(targets)
|
|
253
253
|
raise "Unexpected call to apply(#{targets})" unless @allow_apply
|
|
254
|
+
|
|
254
255
|
targets
|
|
255
256
|
end
|
|
256
257
|
|
|
257
258
|
def await_results(promises)
|
|
258
259
|
raise "Unexpected call to apply(#{targets})" unless @allow_apply
|
|
260
|
+
|
|
259
261
|
Bolt::ResultSet.new(promises.map { |target| Bolt::ApplyResult.new(target) })
|
|
260
262
|
end
|
|
261
263
|
# End Apply mocking
|
|
@@ -329,8 +331,6 @@ module BoltSpec
|
|
|
329
331
|
|
|
330
332
|
def batch_execute(_targets); end
|
|
331
333
|
|
|
332
|
-
def finish_plan(_plan_result); end
|
|
333
|
-
|
|
334
334
|
def handle_event(_event); end
|
|
335
335
|
|
|
336
336
|
def prompt(_prompt, _options); end
|
|
@@ -349,8 +349,6 @@ module BoltSpec
|
|
|
349
349
|
|
|
350
350
|
def shutdown; end
|
|
351
351
|
|
|
352
|
-
def start_plan(_plan_context); end
|
|
353
|
-
|
|
354
352
|
def subscribe(_subscriber, _types = nil); end
|
|
355
353
|
|
|
356
354
|
def unsubscribe(_subscriber, _types = nil); end
|
data/libexec/apply_catalog.rb
CHANGED
|
@@ -57,6 +57,7 @@ begin
|
|
|
57
57
|
# explicitly packaged plugins should take precedence
|
|
58
58
|
args['bolt_builtin_content'].each do |builtin_dir|
|
|
59
59
|
next unless Dir.exist?(builtin_dir)
|
|
60
|
+
|
|
60
61
|
Dir.foreach(builtin_dir) do |dir|
|
|
61
62
|
unless ['.', '..'].include? dir
|
|
62
63
|
full_path = File.join(builtin_dir, dir, 'lib')
|
|
@@ -74,7 +75,7 @@ begin
|
|
|
74
75
|
begin
|
|
75
76
|
require 'puppet/resource_api/transport'
|
|
76
77
|
rescue LoadError
|
|
77
|
-
msg = "Could not load 'puppet/resource_api/transport', puppet-resource_api "\
|
|
78
|
+
msg = "Could not load 'puppet/resource_api/transport', puppet-resource_api " \
|
|
78
79
|
"gem version 1.8.0 or greater is required on the proxy target"
|
|
79
80
|
puts msg
|
|
80
81
|
exit 1
|
data/libexec/custom_facts.rb
CHANGED
|
@@ -39,7 +39,7 @@ Dir.mktmpdir do |puppet_root|
|
|
|
39
39
|
begin
|
|
40
40
|
require 'puppet/resource_api/transport'
|
|
41
41
|
rescue LoadError
|
|
42
|
-
msg = "Could not load 'puppet/resource_api/transport', puppet-resource_api "\
|
|
42
|
+
msg = "Could not load 'puppet/resource_api/transport', puppet-resource_api " \
|
|
43
43
|
"gem version 1.8.0 or greater is required on the proxy target"
|
|
44
44
|
puts msg
|
|
45
45
|
exit 1
|
data/libexec/query_resources.rb
CHANGED
|
@@ -46,7 +46,7 @@ Dir.mktmpdir do |puppet_root|
|
|
|
46
46
|
begin
|
|
47
47
|
require 'puppet/resource_api/transport'
|
|
48
48
|
rescue LoadError
|
|
49
|
-
msg = "Could not load 'puppet/resource_api/transport', puppet-resource_api "\
|
|
49
|
+
msg = "Could not load 'puppet/resource_api/transport', puppet-resource_api " \
|
|
50
50
|
"gem version 1.8.0 or greater is required on the proxy target"
|
|
51
51
|
puts msg
|
|
52
52
|
exit 1
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openbolt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenVox Project
|
|
@@ -147,26 +147,6 @@ dependencies:
|
|
|
147
147
|
- - "~>"
|
|
148
148
|
- !ruby/object:Gem::Version
|
|
149
149
|
version: '2.2'
|
|
150
|
-
- !ruby/object:Gem::Dependency
|
|
151
|
-
name: minitar
|
|
152
|
-
requirement: !ruby/object:Gem::Requirement
|
|
153
|
-
requirements:
|
|
154
|
-
- - ">="
|
|
155
|
-
- !ruby/object:Gem::Version
|
|
156
|
-
version: '0.6'
|
|
157
|
-
- - "<"
|
|
158
|
-
- !ruby/object:Gem::Version
|
|
159
|
-
version: '2.0'
|
|
160
|
-
type: :runtime
|
|
161
|
-
prerelease: false
|
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
-
requirements:
|
|
164
|
-
- - ">="
|
|
165
|
-
- !ruby/object:Gem::Version
|
|
166
|
-
version: '0.6'
|
|
167
|
-
- - "<"
|
|
168
|
-
- !ruby/object:Gem::Version
|
|
169
|
-
version: '2.0'
|
|
170
150
|
- !ruby/object:Gem::Dependency
|
|
171
151
|
name: net-scp
|
|
172
152
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -239,30 +219,22 @@ dependencies:
|
|
|
239
219
|
name: openvox-strings
|
|
240
220
|
requirement: !ruby/object:Gem::Requirement
|
|
241
221
|
requirements:
|
|
242
|
-
- - "
|
|
222
|
+
- - ">="
|
|
243
223
|
- !ruby/object:Gem::Version
|
|
244
224
|
version: '5.0'
|
|
225
|
+
- - "<"
|
|
226
|
+
- !ruby/object:Gem::Version
|
|
227
|
+
version: '7'
|
|
245
228
|
type: :runtime
|
|
246
229
|
prerelease: false
|
|
247
230
|
version_requirements: !ruby/object:Gem::Requirement
|
|
248
231
|
requirements:
|
|
249
|
-
- - "
|
|
232
|
+
- - ">="
|
|
250
233
|
- !ruby/object:Gem::Version
|
|
251
234
|
version: '5.0'
|
|
252
|
-
-
|
|
253
|
-
name: orchestrator_client
|
|
254
|
-
requirement: !ruby/object:Gem::Requirement
|
|
255
|
-
requirements:
|
|
256
|
-
- - "~>"
|
|
257
|
-
- !ruby/object:Gem::Version
|
|
258
|
-
version: '0.7'
|
|
259
|
-
type: :runtime
|
|
260
|
-
prerelease: false
|
|
261
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
262
|
-
requirements:
|
|
263
|
-
- - "~>"
|
|
235
|
+
- - "<"
|
|
264
236
|
- !ruby/object:Gem::Version
|
|
265
|
-
version: '
|
|
237
|
+
version: '7'
|
|
266
238
|
- !ruby/object:Gem::Dependency
|
|
267
239
|
name: puppetfile-resolver
|
|
268
240
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -306,7 +278,7 @@ dependencies:
|
|
|
306
278
|
version: '3.10'
|
|
307
279
|
- - "<"
|
|
308
280
|
- !ruby/object:Gem::Version
|
|
309
|
-
version: '
|
|
281
|
+
version: '6'
|
|
310
282
|
type: :runtime
|
|
311
283
|
prerelease: false
|
|
312
284
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -316,27 +288,21 @@ dependencies:
|
|
|
316
288
|
version: '3.10'
|
|
317
289
|
- - "<"
|
|
318
290
|
- !ruby/object:Gem::Version
|
|
319
|
-
version: '
|
|
291
|
+
version: '6'
|
|
320
292
|
- !ruby/object:Gem::Dependency
|
|
321
293
|
name: ruby_smb
|
|
322
294
|
requirement: !ruby/object:Gem::Requirement
|
|
323
295
|
requirements:
|
|
324
|
-
- - "
|
|
296
|
+
- - "~>"
|
|
325
297
|
- !ruby/object:Gem::Version
|
|
326
298
|
version: '1.0'
|
|
327
|
-
- - "<"
|
|
328
|
-
- !ruby/object:Gem::Version
|
|
329
|
-
version: 4.0.0
|
|
330
299
|
type: :runtime
|
|
331
300
|
prerelease: false
|
|
332
301
|
version_requirements: !ruby/object:Gem::Requirement
|
|
333
302
|
requirements:
|
|
334
|
-
- - "
|
|
303
|
+
- - "~>"
|
|
335
304
|
- !ruby/object:Gem::Version
|
|
336
305
|
version: '1.0'
|
|
337
|
-
- - "<"
|
|
338
|
-
- !ruby/object:Gem::Version
|
|
339
|
-
version: 4.0.0
|
|
340
306
|
- !ruby/object:Gem::Dependency
|
|
341
307
|
name: terminal-table
|
|
342
308
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -459,14 +425,34 @@ dependencies:
|
|
|
459
425
|
requirements:
|
|
460
426
|
- - "~>"
|
|
461
427
|
- !ruby/object:Gem::Version
|
|
462
|
-
version:
|
|
428
|
+
version: 5.0.0
|
|
463
429
|
type: :development
|
|
464
430
|
prerelease: false
|
|
465
431
|
version_requirements: !ruby/object:Gem::Requirement
|
|
466
432
|
requirements:
|
|
467
433
|
- - "~>"
|
|
468
434
|
- !ruby/object:Gem::Version
|
|
469
|
-
version:
|
|
435
|
+
version: 5.0.0
|
|
436
|
+
- !ruby/object:Gem::Dependency
|
|
437
|
+
name: minitar
|
|
438
|
+
requirement: !ruby/object:Gem::Requirement
|
|
439
|
+
requirements:
|
|
440
|
+
- - ">="
|
|
441
|
+
- !ruby/object:Gem::Version
|
|
442
|
+
version: '0.6'
|
|
443
|
+
- - "<"
|
|
444
|
+
- !ruby/object:Gem::Version
|
|
445
|
+
version: '2.0'
|
|
446
|
+
type: :runtime
|
|
447
|
+
prerelease: false
|
|
448
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
449
|
+
requirements:
|
|
450
|
+
- - ">="
|
|
451
|
+
- !ruby/object:Gem::Version
|
|
452
|
+
version: '0.6'
|
|
453
|
+
- - "<"
|
|
454
|
+
- !ruby/object:Gem::Version
|
|
455
|
+
version: '2.0'
|
|
470
456
|
description: Execute commands remotely over SSH and WinRM
|
|
471
457
|
email:
|
|
472
458
|
- openvox@voxpupuli.org
|
|
@@ -569,7 +555,6 @@ files:
|
|
|
569
555
|
- lib/bolt/config/transport/local.rb
|
|
570
556
|
- lib/bolt/config/transport/lxd.rb
|
|
571
557
|
- lib/bolt/config/transport/options.rb
|
|
572
|
-
- lib/bolt/config/transport/orch.rb
|
|
573
558
|
- lib/bolt/config/transport/podman.rb
|
|
574
559
|
- lib/bolt/config/transport/remote.rb
|
|
575
560
|
- lib/bolt/config/transport/ssh.rb
|
|
@@ -669,8 +654,6 @@ files:
|
|
|
669
654
|
- lib/bolt/transport/local/connection.rb
|
|
670
655
|
- lib/bolt/transport/lxd.rb
|
|
671
656
|
- lib/bolt/transport/lxd/connection.rb
|
|
672
|
-
- lib/bolt/transport/orch.rb
|
|
673
|
-
- lib/bolt/transport/orch/connection.rb
|
|
674
657
|
- lib/bolt/transport/podman.rb
|
|
675
658
|
- lib/bolt/transport/podman/connection.rb
|
|
676
659
|
- lib/bolt/transport/remote.rb
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative '../../../bolt/error'
|
|
4
|
-
require_relative '../../../bolt/config/transport/base'
|
|
5
|
-
|
|
6
|
-
module Bolt
|
|
7
|
-
class Config
|
|
8
|
-
module Transport
|
|
9
|
-
class Orch < Base
|
|
10
|
-
OPTIONS = %w[
|
|
11
|
-
cacert
|
|
12
|
-
host
|
|
13
|
-
job-poll-interval
|
|
14
|
-
job-poll-timeout
|
|
15
|
-
read-timeout
|
|
16
|
-
service-url
|
|
17
|
-
task-environment
|
|
18
|
-
token-file
|
|
19
|
-
].freeze
|
|
20
|
-
|
|
21
|
-
DEFAULTS = {
|
|
22
|
-
"task-environment" => "production"
|
|
23
|
-
}.freeze
|
|
24
|
-
|
|
25
|
-
private def validate
|
|
26
|
-
super
|
|
27
|
-
|
|
28
|
-
if @config['cacert']
|
|
29
|
-
@config['cacert'] = File.expand_path(@config['cacert'], @project)
|
|
30
|
-
Bolt::Util.validate_file('cacert', @config['cacert'])
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
if @config['token-file']
|
|
34
|
-
@config['token-file'] = File.expand_path(@config['token-file'], @project)
|
|
35
|
-
Bolt::Util.validate_file('token-file', @config['token-file'])
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bolt
|
|
4
|
-
module Transport
|
|
5
|
-
class Orch < Base
|
|
6
|
-
class Connection
|
|
7
|
-
attr_reader :logger, :key
|
|
8
|
-
|
|
9
|
-
CONTEXT_KEYS = Set.new(%i[plan_name description params sensitive]).freeze
|
|
10
|
-
|
|
11
|
-
def self.get_key(opts)
|
|
12
|
-
[
|
|
13
|
-
opts['service-url'],
|
|
14
|
-
opts['task-environment'],
|
|
15
|
-
opts['token-file']
|
|
16
|
-
].join('-')
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def initialize(opts, plan_context, logger)
|
|
20
|
-
require 'addressable/uri'
|
|
21
|
-
|
|
22
|
-
@logger = logger
|
|
23
|
-
@key = self.class.get_key(opts)
|
|
24
|
-
client_opts = opts.slice('token-file', 'cacert', 'job-poll-interval', 'job-poll-timeout', 'read-timeout')
|
|
25
|
-
|
|
26
|
-
if opts['service-url']
|
|
27
|
-
uri = Addressable::URI.parse(opts['service-url'])
|
|
28
|
-
uri&.port ||= 8143
|
|
29
|
-
client_opts['service-url'] = uri.to_s
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
client_opts['User-Agent'] = "Bolt/#{VERSION}"
|
|
33
|
-
|
|
34
|
-
%w[token-file cacert].each do |f|
|
|
35
|
-
client_opts[f] = File.expand_path(client_opts[f]) if client_opts[f]
|
|
36
|
-
end
|
|
37
|
-
logger.debug("Creating orchestrator client for #{client_opts}")
|
|
38
|
-
@client = OrchestratorClient.new(client_opts, true)
|
|
39
|
-
@plan_context = plan_context
|
|
40
|
-
@plan_job = start_plan(@plan_context)
|
|
41
|
-
logger.debug("Started plan #{@plan_job}")
|
|
42
|
-
@environment = opts["task-environment"]
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def start_plan(plan_context)
|
|
46
|
-
if plan_context
|
|
47
|
-
begin
|
|
48
|
-
opts = plan_context.select { |k, _| CONTEXT_KEYS.include? k }
|
|
49
|
-
opts[:params] = opts[:params].reject { |k, _| plan_context[:sensitive].include?(k) }
|
|
50
|
-
@client.command.plan_start(opts)['name']
|
|
51
|
-
rescue OrchestratorClient::ApiError => e
|
|
52
|
-
if e.code == '404'
|
|
53
|
-
@logger.debug("Orchestrator #{key} does not support plans")
|
|
54
|
-
else
|
|
55
|
-
@logger.error("Failed to start a plan with orchestrator #{key}: #{e.message}")
|
|
56
|
-
end
|
|
57
|
-
nil
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def finish_plan(plan_result)
|
|
63
|
-
if @plan_job
|
|
64
|
-
@client.command.plan_finish(
|
|
65
|
-
plan_job: @plan_job,
|
|
66
|
-
result: plan_result.value || '',
|
|
67
|
-
status: plan_result.status
|
|
68
|
-
)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def get_certnames(targets)
|
|
73
|
-
targets.map { |t| t.host || t.name }
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def build_request(targets, task, arguments, description = nil)
|
|
77
|
-
body = { task: task.name,
|
|
78
|
-
environment: @environment,
|
|
79
|
-
noop: arguments['_noop'],
|
|
80
|
-
params: arguments.reject { |k, _| k.start_with?('_') },
|
|
81
|
-
scope: {
|
|
82
|
-
nodes: get_certnames(targets)
|
|
83
|
-
} }
|
|
84
|
-
body[:description] = description if description
|
|
85
|
-
body[:plan_job] = @plan_job if @plan_job
|
|
86
|
-
body
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def run_task(targets, task, arguments, options)
|
|
90
|
-
body = build_request(targets, task, arguments, options[:description])
|
|
91
|
-
@client.run_task(body)
|
|
92
|
-
rescue OrchestratorClient::ApiError => e
|
|
93
|
-
if e.data['kind'] == 'puppetlabs.orchestrator/plan-already-finished'
|
|
94
|
-
@logger.debug("Retrying the task")
|
|
95
|
-
# Instead of recursing, just retry once
|
|
96
|
-
@plan_job = start_plan(@plan_context)
|
|
97
|
-
# Rebuild the request with the new plan job ID
|
|
98
|
-
body = build_request(targets, task, arguments, options[:description])
|
|
99
|
-
@client.run_task(body)
|
|
100
|
-
else
|
|
101
|
-
raise e
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def query_inventory(targets)
|
|
106
|
-
@client.post('inventory', nodes: get_certnames(targets))
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|