bolt 3.0.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bolt might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Puppetfile +13 -11
- data/bolt-modules/boltlib/lib/puppet/datatypes/containerresult.rb +24 -0
- data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +20 -2
- data/bolt-modules/boltlib/lib/puppet/functions/run_container.rb +162 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +2 -2
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +44 -5
- data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +1 -1
- data/bolt-modules/boltlib/types/planresult.pp +1 -0
- data/bolt-modules/file/lib/puppet/functions/file/read.rb +3 -2
- data/bolt-modules/prompt/lib/puppet/functions/prompt.rb +20 -2
- data/bolt-modules/prompt/lib/puppet/functions/prompt/menu.rb +103 -0
- data/lib/bolt/analytics.rb +4 -8
- data/lib/bolt/apply_result.rb +1 -1
- data/lib/bolt/bolt_option_parser.rb +6 -3
- data/lib/bolt/cli.rb +123 -37
- data/lib/bolt/config.rb +15 -7
- data/lib/bolt/config/options.rb +62 -12
- data/lib/bolt/config/transport/lxd.rb +23 -0
- data/lib/bolt/config/transport/options.rb +8 -1
- data/lib/bolt/config/transport/podman.rb +33 -0
- data/lib/bolt/container_result.rb +105 -0
- data/lib/bolt/error.rb +15 -0
- data/lib/bolt/executor.rb +37 -18
- data/lib/bolt/inventory/options.rb +9 -0
- data/lib/bolt/inventory/target.rb +16 -0
- data/lib/bolt/logger.rb +8 -0
- data/lib/bolt/module_installer.rb +2 -2
- data/lib/bolt/module_installer/puppetfile.rb +2 -2
- data/lib/bolt/module_installer/specs/forge_spec.rb +2 -2
- data/lib/bolt/module_installer/specs/git_spec.rb +2 -2
- data/lib/bolt/node/output.rb +14 -4
- data/lib/bolt/outputter/human.rb +259 -90
- data/lib/bolt/outputter/json.rb +3 -1
- data/lib/bolt/outputter/logger.rb +17 -0
- data/lib/bolt/pal.rb +25 -4
- data/lib/bolt/pal/yaml_plan.rb +1 -2
- data/lib/bolt/pal/yaml_plan/evaluator.rb +5 -141
- data/lib/bolt/pal/yaml_plan/step.rb +91 -31
- data/lib/bolt/pal/yaml_plan/step/command.rb +21 -13
- data/lib/bolt/pal/yaml_plan/step/download.rb +15 -16
- data/lib/bolt/pal/yaml_plan/step/eval.rb +11 -11
- data/lib/bolt/pal/yaml_plan/step/message.rb +13 -4
- data/lib/bolt/pal/yaml_plan/step/plan.rb +19 -15
- data/lib/bolt/pal/yaml_plan/step/resources.rb +82 -21
- data/lib/bolt/pal/yaml_plan/step/script.rb +36 -17
- data/lib/bolt/pal/yaml_plan/step/task.rb +19 -16
- data/lib/bolt/pal/yaml_plan/step/upload.rb +16 -17
- data/lib/bolt/pal/yaml_plan/transpiler.rb +3 -3
- data/lib/bolt/plan_creator.rb +1 -1
- data/lib/bolt/plugin.rb +13 -11
- data/lib/bolt/project_manager.rb +1 -1
- data/lib/bolt/project_manager/module_migrator.rb +1 -1
- data/lib/bolt/result.rb +11 -15
- data/lib/bolt/shell.rb +16 -0
- data/lib/bolt/shell/bash.rb +61 -31
- data/lib/bolt/shell/bash/tmpdir.rb +2 -2
- data/lib/bolt/shell/powershell.rb +34 -12
- data/lib/bolt/shell/powershell/snippets.rb +30 -3
- data/lib/bolt/task.rb +1 -1
- data/lib/bolt/transport/base.rb +0 -9
- data/lib/bolt/transport/docker.rb +2 -126
- data/lib/bolt/transport/docker/connection.rb +81 -167
- data/lib/bolt/transport/lxd.rb +26 -0
- data/lib/bolt/transport/lxd/connection.rb +99 -0
- data/lib/bolt/transport/orch.rb +13 -5
- data/lib/bolt/transport/podman.rb +19 -0
- data/lib/bolt/transport/podman/connection.rb +98 -0
- data/lib/bolt/transport/ssh/connection.rb +1 -1
- data/lib/bolt/transport/winrm/connection.rb +1 -1
- data/lib/bolt/util.rb +42 -0
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/transport_app.rb +64 -33
- data/lib/bolt_spec/bolt_context.rb +9 -4
- data/lib/bolt_spec/plans.rb +1 -109
- data/lib/bolt_spec/plans/action_stubs.rb +1 -1
- data/lib/bolt_spec/plans/action_stubs/command_stub.rb +8 -1
- data/lib/bolt_spec/plans/action_stubs/script_stub.rb +8 -1
- data/lib/bolt_spec/plans/mock_executor.rb +91 -7
- data/modules/puppet_connect/plans/test_input_data.pp +65 -7
- metadata +12 -2
@@ -130,11 +130,16 @@ module BoltSpec
|
|
130
130
|
@executor ||= BoltSpec::Plans::MockExecutor.new(modulepath)
|
131
131
|
end
|
132
132
|
|
133
|
-
#
|
133
|
+
# Overrides inventory for tests.
|
134
134
|
def inventory_data
|
135
135
|
{}
|
136
136
|
end
|
137
137
|
|
138
|
+
# Overrides configuration for tests.
|
139
|
+
def config_data
|
140
|
+
{}
|
141
|
+
end
|
142
|
+
|
138
143
|
def inventory
|
139
144
|
@inventory ||= Bolt::Inventory.create_version(inventory_data, config.transport, config.transports, plugins)
|
140
145
|
end
|
@@ -142,7 +147,7 @@ module BoltSpec
|
|
142
147
|
# Override in your tests
|
143
148
|
def config
|
144
149
|
@config ||= begin
|
145
|
-
conf = Bolt::Config.
|
150
|
+
conf = Bolt::Config.new(Bolt::Project.default_project, config_data)
|
146
151
|
conf.modulepath = [modulepath].flatten
|
147
152
|
conf
|
148
153
|
end
|
@@ -161,7 +166,7 @@ module BoltSpec
|
|
161
166
|
BoltSpec::Plans::MOCKED_ACTIONS.each do |action|
|
162
167
|
# Allowed action stubs can be called up to be_called_times number of times
|
163
168
|
define_method :"allow_#{action}" do |object|
|
164
|
-
executor.send(:"stub_#{action}", object).add_stub
|
169
|
+
executor.send(:"stub_#{action}", object).add_stub(inventory)
|
165
170
|
end
|
166
171
|
|
167
172
|
# Expected action stubs must be called exactly the expected number of times
|
@@ -172,7 +177,7 @@ module BoltSpec
|
|
172
177
|
|
173
178
|
# This stub will catch any action call if there are no stubs specifically for that task
|
174
179
|
define_method :"allow_any_#{action}" do
|
175
|
-
executor.send(:"stub_#{action}", :default).add_stub
|
180
|
+
executor.send(:"stub_#{action}", :default).add_stub(inventory)
|
176
181
|
end
|
177
182
|
end
|
178
183
|
|
data/lib/bolt_spec/plans.rb
CHANGED
@@ -5,119 +5,11 @@ require 'bolt_spec/plans/mock_executor'
|
|
5
5
|
require 'bolt/pal'
|
6
6
|
|
7
7
|
# These helpers are intended to be used for plan unit testing without calling
|
8
|
-
# out to
|
8
|
+
# out to targets. It uses the BoltContext helper to set up a mock executor
|
9
9
|
# which allows calls to run_* functions to be stubbed for testing. The context
|
10
10
|
# helper also loads Bolt datatypes and plan functions to be used by the code
|
11
11
|
# being tested.
|
12
12
|
#
|
13
|
-
# Stub matching
|
14
|
-
#
|
15
|
-
# Stubs match invocations of run_* functions by default matching any call but
|
16
|
-
# with_targets and with_params helpers can further restrict the stub to match
|
17
|
-
# more exact invocations. It's possible a call to run_* could match multiple
|
18
|
-
# stubs. In this case the mock executor will first check for stubs specifically
|
19
|
-
# matching the task being run after which it will use the last stub that
|
20
|
-
# matched
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# allow vs expect
|
24
|
-
#
|
25
|
-
# Stubs have two general modes bases on whether the test is making assertions
|
26
|
-
# on whether function was called. Allow stubs allow the run_* invocation to
|
27
|
-
# be called any number of times while expect stubs will fail if no run_*
|
28
|
-
# invocation matches them. The be_called_times(n) stub method can be used to
|
29
|
-
# ensure an allow stub is not called more than n times or that an expect stub
|
30
|
-
# is called exactly n times.
|
31
|
-
#
|
32
|
-
# Configuration
|
33
|
-
#
|
34
|
-
# To configure Puppet and Bolt at the beginning of tests, add the following
|
35
|
-
# line to your spec_helper.rb:
|
36
|
-
#
|
37
|
-
# BoltSpec::Plans.init
|
38
|
-
#
|
39
|
-
# By default the plan helpers use the modulepath set up for rspec-puppet and
|
40
|
-
# an otherwise empty bolt config and inventory. To create your own values for
|
41
|
-
# these override the modulepath, config, or inventory methods.
|
42
|
-
#
|
43
|
-
# Sub-plan Execution
|
44
|
-
#
|
45
|
-
# When testing a plan, often times those plans call other plans in order to
|
46
|
-
# build complex workflows. To support this we offer running in two different
|
47
|
-
# modes:
|
48
|
-
# execute_any_plan (default) - This mode will execute any plan that is encountered
|
49
|
-
# without having to be stubbed/mocked. This default mode allows for plan control
|
50
|
-
# flow to behave as normal. If you choose to stub/mock out a sub-plan in this mode
|
51
|
-
# that will be honored and the sub-plan will not be executed. We will use the modifiers
|
52
|
-
# on the stub to check for the conditions specified (example: be_called_times(3))
|
53
|
-
#
|
54
|
-
# execute_no_plan - This mode will not execute a plans that it encounters. Instead, when
|
55
|
-
# a plan is encountered it will throw an error unless the plan is mocked out. This
|
56
|
-
# mode is useful for ensuring that there are no plans called that you do not expect.
|
57
|
-
# This plan requires authors to mock out all sub-plans that may be invoked when running
|
58
|
-
# tests.
|
59
|
-
#
|
60
|
-
# TODO:
|
61
|
-
# - Allow description based stub matching
|
62
|
-
# - Better testing of plan errors
|
63
|
-
# - Better error collection around call counts. Show what stubs exists and more than a single failure
|
64
|
-
# - Allow stubbing with a block(at the double level? As a matched stub?)
|
65
|
-
# - package code so that it can be used for testing modules outside of this repo
|
66
|
-
# - set subject from describe and provide matchers similar to rspec puppets function tests
|
67
|
-
# - Allow specific plans to be executed when running in execute_no_plan mode.
|
68
|
-
#
|
69
|
-
# MAYBE TODO?:
|
70
|
-
# - validate call expectations at the end of the example instead of in run_plan
|
71
|
-
# - resultset matchers to help testing canary like plans?
|
72
|
-
# - inventory matchers to help testing plans that change inventory
|
73
|
-
#
|
74
|
-
# Flags:
|
75
|
-
# - execute_any_plan: execute any plan that is encountered unless it is mocked (default)
|
76
|
-
# - execute_no_plan: throw an error if a plan is encountered that is not stubbed
|
77
|
-
#
|
78
|
-
# Stubs:
|
79
|
-
# - allow_command(cmd), expect_command(cmd): expect the exact command
|
80
|
-
# - allow_plan(plan), expect_plan(plan): expect the named plan
|
81
|
-
# - allow_script(script), expect_script(script): expect the script as <module>/path/to/file
|
82
|
-
# - allow_task(task), expect_task(task): expect the named task
|
83
|
-
# - allow_download(file), expect_download(file): expect the identified source file
|
84
|
-
# - allow_upload(file), expect_upload(file): expect the identified source file
|
85
|
-
# - allow_apply_prep: allows `apply_prep` to be invoked in the plan but does not allow modifiers
|
86
|
-
# - allow_apply: allows `apply` to be invoked in the plan but does not allow modifiers
|
87
|
-
# - allow_out_message, expect_out_message: expect a message to be passed to out::message (only modifiers are
|
88
|
-
# be_called_times(n), with_params(params), and not_be_called)
|
89
|
-
#
|
90
|
-
# Stub modifiers:
|
91
|
-
# - be_called_times(n): if allowed, fail if the action is called more than 'n' times
|
92
|
-
# if expected, fail unless the action is called 'n' times
|
93
|
-
# - not_be_called: fail if the action is called
|
94
|
-
# - with_targets(targets): target or list of targets that you expect to be passed to the action
|
95
|
-
# plan: does not support this modifier
|
96
|
-
# - with_params(params): list of params and metaparams (or options) that you expect to be passed to the action.
|
97
|
-
# Corresponds to the action's last argument.
|
98
|
-
# - with_destination(dest): for upload_file and download_file, the expected destination path
|
99
|
-
# - always_return(value): return a Bolt::ResultSet of Bolt::Result objects with the specified value Hash
|
100
|
-
# plan: returns a Bolt::PlanResult with the specified value with a status of 'success'
|
101
|
-
# command and script: only accept 'stdout' and 'stderr' keys
|
102
|
-
# upload: does not support this modifier
|
103
|
-
# download: does not support this modifier
|
104
|
-
# - return_for_targets(targets_to_values): return a Bolt::ResultSet of Bolt::Result objects from the Hash mapping
|
105
|
-
# targets to their value Hashes
|
106
|
-
# command and script: only accept 'stdout' and 'stderr' keys
|
107
|
-
# upload: does not support this modifier
|
108
|
-
# download: does not support this modifier
|
109
|
-
# plan: does not support this modifier
|
110
|
-
# - return(&block): invoke the block to construct a Bolt::ResultSet. The blocks parameters differ based on action
|
111
|
-
# command: `{ |targets:, command:, params:| ... }`
|
112
|
-
# plan: `{ |plan:, params:| ... }`
|
113
|
-
# script: `{ |targets:, script:, params:| ... }`
|
114
|
-
# task: `{ |targets:, task:, params:| ... }`
|
115
|
-
# upload: `{ |targets:, source:, destination:, params:| ... }`
|
116
|
-
# download: `{ |targets:, source:, destination:, params:| ... }`
|
117
|
-
# - error_with(err): return a failing Bolt::ResultSet, with Bolt::Result objects with the identified err hash
|
118
|
-
# plans will throw a Bolt::PlanFailure that will be returned as the value of
|
119
|
-
# the Bolt::PlanResult object with a status of 'failure'.
|
120
|
-
#
|
121
13
|
# Example:
|
122
14
|
# describe "my_plan" do
|
123
15
|
# it 'should return' do
|
@@ -177,7 +177,7 @@ module BoltSpec
|
|
177
177
|
if data['msg'] && data['kind'] && (data.keys - %w[msg kind details issue_code]).empty?
|
178
178
|
@data[:default] = clazz.new(data['msg'], data['kind'], data['details'], data['issue_code'])
|
179
179
|
else
|
180
|
-
$stderr.puts "In the future 'error_with()'
|
180
|
+
$stderr.puts "In the future 'error_with()' might require msg and kind, and " \
|
181
181
|
"optionally accept only details and issue_code."
|
182
182
|
@data[:default] = data
|
183
183
|
end
|
@@ -29,7 +29,14 @@ module BoltSpec
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def result_for(target, stdout: '', stderr: '')
|
32
|
-
|
32
|
+
value = {
|
33
|
+
'stdout' => stdout,
|
34
|
+
'stderr' => stderr,
|
35
|
+
'merged_output' => "#{stdout}\n#{stderr}".strip,
|
36
|
+
'exit_code' => 0
|
37
|
+
}
|
38
|
+
|
39
|
+
Bolt::Result.for_command(target, value, 'command', '', [])
|
33
40
|
end
|
34
41
|
|
35
42
|
# Public methods
|
@@ -35,7 +35,14 @@ module BoltSpec
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def result_for(target, stdout: '', stderr: '')
|
38
|
-
|
38
|
+
value = {
|
39
|
+
'stdout' => stdout,
|
40
|
+
'stderr' => stderr,
|
41
|
+
'merged_output' => "#{stdout}\n#{stderr}".strip,
|
42
|
+
'exit_code' => 0
|
43
|
+
}
|
44
|
+
|
45
|
+
Bolt::Result.for_command(target, value, 'script', '', [])
|
39
46
|
end
|
40
47
|
|
41
48
|
# Public methods
|
@@ -17,13 +17,14 @@ module BoltSpec
|
|
17
17
|
|
18
18
|
# Nothing on the executor is 'public'
|
19
19
|
class MockExecutor
|
20
|
-
attr_reader :noop, :error_message, :in_parallel
|
20
|
+
attr_reader :noop, :error_message, :in_parallel, :transports, :future
|
21
21
|
attr_accessor :run_as, :transport_features, :execute_any_plan
|
22
22
|
|
23
23
|
def initialize(modulepath)
|
24
24
|
@noop = false
|
25
25
|
@run_as = nil
|
26
26
|
@in_parallel = false
|
27
|
+
@future = {}
|
27
28
|
@error_message = nil
|
28
29
|
@allow_apply = false
|
29
30
|
@modulepath = [modulepath].flatten.map { |path| File.absolute_path(path) }
|
@@ -91,6 +92,14 @@ module BoltSpec
|
|
91
92
|
result
|
92
93
|
end
|
93
94
|
|
95
|
+
def run_task_with(target_mapping, task, options = {}, _position = [])
|
96
|
+
resultsets = target_mapping.map do |target, arguments|
|
97
|
+
run_task([target], task, arguments, options)
|
98
|
+
end.compact
|
99
|
+
|
100
|
+
Bolt::ResultSet.new(resultsets.map(&:results).flatten)
|
101
|
+
end
|
102
|
+
|
94
103
|
def download_file(targets, source, destination, options = {}, _position = [])
|
95
104
|
result = nil
|
96
105
|
if (doub = @download_doubles[source] || @download_doubles[:default])
|
@@ -210,12 +219,6 @@ module BoltSpec
|
|
210
219
|
yield
|
211
220
|
end
|
212
221
|
|
213
|
-
def report_function_call(_function); end
|
214
|
-
|
215
|
-
def report_bundled_content(_mode, _name); end
|
216
|
-
|
217
|
-
def report_apply(_statements, _resources); end
|
218
|
-
|
219
222
|
def publish_event(event)
|
220
223
|
if event[:type] == :message
|
221
224
|
unless @stub_out_message
|
@@ -253,6 +256,87 @@ module BoltSpec
|
|
253
256
|
end.new(transport_features)
|
254
257
|
end
|
255
258
|
# End apply_prep mocking
|
259
|
+
|
260
|
+
# Evaluates a `parallelize()` block and returns the result. Normally,
|
261
|
+
# Bolt's executor wraps this in a Yarn for each object passed to the
|
262
|
+
# `parallelize()` function, and then executes them in parallel before
|
263
|
+
# returning the result from the block. However, in BoltSpec the block is
|
264
|
+
# executed for each object sequentially, and this function returns the
|
265
|
+
# result itself.
|
266
|
+
#
|
267
|
+
def create_yarn(scope, block, object, _index)
|
268
|
+
# Create the new scope
|
269
|
+
newscope = Puppet::Parser::Scope.new(scope.compiler)
|
270
|
+
local = Puppet::Parser::Scope::LocalScope.new
|
271
|
+
|
272
|
+
# Compress the current scopes into a single vars hash to add to the new scope
|
273
|
+
current_scope = scope.effective_symtable(true)
|
274
|
+
until current_scope.nil?
|
275
|
+
current_scope.instance_variable_get(:@symbols)&.each_pair { |k, v| local[k] = v }
|
276
|
+
current_scope = current_scope.parent
|
277
|
+
end
|
278
|
+
newscope.push_ephemerals([local])
|
279
|
+
|
280
|
+
begin
|
281
|
+
result = catch(:return) do
|
282
|
+
args = { block.parameters[0][1].to_s => object }
|
283
|
+
block.closure.call_by_name_with_scope(newscope, args, true)
|
284
|
+
end
|
285
|
+
|
286
|
+
# If we got a return from the block, get it's value
|
287
|
+
# Otherwise the result is the last line from the block
|
288
|
+
result = result.value if result.is_a?(Puppet::Pops::Evaluator::Return)
|
289
|
+
|
290
|
+
# Validate the result is a PlanResult
|
291
|
+
unless Puppet::Pops::Types::TypeParser.singleton.parse('Boltlib::PlanResult').instance?(result)
|
292
|
+
raise Bolt::InvalidParallelResult.new(result.to_s, *Puppet::Pops::PuppetStack.top_of_stack)
|
293
|
+
end
|
294
|
+
|
295
|
+
result
|
296
|
+
rescue Puppet::PreformattedError => e
|
297
|
+
if e.cause.is_a?(Bolt::Error)
|
298
|
+
e.cause
|
299
|
+
else
|
300
|
+
raise e
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
# BoltSpec already evaluated the `parallelize()` block for each object
|
306
|
+
# passed to the function, so these results can be returned as-is.
|
307
|
+
#
|
308
|
+
def round_robin(results)
|
309
|
+
results
|
310
|
+
end
|
311
|
+
|
312
|
+
# Public methods on Bolt::Executor that need to be mocked so there aren't
|
313
|
+
# "undefined method" errors.
|
314
|
+
|
315
|
+
def batch_execute(_targets); end
|
316
|
+
|
317
|
+
def finish_plan(_plan_result); end
|
318
|
+
|
319
|
+
def handle_event(_event); end
|
320
|
+
|
321
|
+
def prompt(_prompt, _options); end
|
322
|
+
|
323
|
+
def report_function_call(_function); end
|
324
|
+
|
325
|
+
def report_bundled_content(_mode, _name); end
|
326
|
+
|
327
|
+
def report_file_source(_plan_function, _source); end
|
328
|
+
|
329
|
+
def report_apply(_statements, _resources); end
|
330
|
+
|
331
|
+
def report_yaml_plan(_plan); end
|
332
|
+
|
333
|
+
def shutdown; end
|
334
|
+
|
335
|
+
def start_plan(_plan_context); end
|
336
|
+
|
337
|
+
def subscribe(_subscriber, _types = nil); end
|
338
|
+
|
339
|
+
def unsubscribe(_subscriber, _types = nil); end
|
256
340
|
end
|
257
341
|
end
|
258
342
|
end
|
@@ -13,15 +13,73 @@
|
|
13
13
|
#
|
14
14
|
plan puppet_connect::test_input_data(TargetSpec $targets = 'all') {
|
15
15
|
$targs = get_targets($targets)
|
16
|
+
$unique_plugins = $targs.group_by |$t| {$t.plugin_hooks['puppet_library']}
|
17
|
+
if ($unique_plugins.keys.length > 1) {
|
18
|
+
out::message('Multiple puppet_library plugin hooks detected')
|
19
|
+
$unique_plugins.each |$plug, $target_list| {
|
20
|
+
$target_message = if ($target_list.length > 10) {
|
21
|
+
"${target_list.length} targets"
|
22
|
+
} else {
|
23
|
+
$target_list.join(', ')
|
24
|
+
}
|
25
|
+
out::message("Plugin hook ${plug} configured for ${target_message}")
|
26
|
+
}
|
27
|
+
fail_plan("The puppet_library plugin config must be the same across all targets")
|
28
|
+
}
|
16
29
|
$targs.each |$target| {
|
17
|
-
|
18
|
-
|
30
|
+
case $target.transport {
|
31
|
+
'ssh': {
|
32
|
+
$private_key_config = dig($target.config, 'ssh', 'private-key')
|
33
|
+
if $private_key_config =~ String {
|
34
|
+
$msg = @("END")
|
35
|
+
The SSH private key of the ${$target} target points to a filepath on disk,
|
36
|
+
which is not allowed in Puppet Connect. Instead, the private key contents must
|
37
|
+
be specified and this should be done via the PuppetConnectData plugin. Below is
|
38
|
+
an example of a Puppet Connect-compatible specification of the private-key. First,
|
39
|
+
we start with the inventory file:
|
40
|
+
...
|
41
|
+
private-key:
|
42
|
+
_plugin: puppet_connect_data
|
43
|
+
key: ssh_private_key
|
44
|
+
...
|
45
|
+
|
46
|
+
Next is the corresponding entry in the input data file:
|
47
|
+
...
|
48
|
+
ssh_private_key:
|
49
|
+
key-data:
|
50
|
+
<private_key_contents>
|
51
|
+
...
|
52
|
+
| END
|
53
|
+
|
54
|
+
out::message($msg)
|
55
|
+
fail_plan("The SSH private key of the ${$target} target points to a filepath on disk")
|
56
|
+
}
|
57
|
+
|
58
|
+
# Disable SSH autoloading to prevent false positive results
|
59
|
+
# (input data is wrong but target is still connectable due
|
60
|
+
# to autoloaded config)
|
61
|
+
set_config($target, ['ssh', 'load-config'], false)
|
62
|
+
# Maintain configuration parity with Puppet Connect to improve
|
63
|
+
# the reliability of our test
|
64
|
+
set_config($target, ['ssh', 'host-key-check'], false)
|
65
|
+
}
|
66
|
+
'winrm': {
|
67
|
+
# Maintain configuration parity with Puppet Connect
|
68
|
+
set_config($target, ['winrm', 'ssl'], false)
|
69
|
+
set_config($target, ['winrm', 'ssl-verify'], false)
|
70
|
+
}
|
71
|
+
default: {
|
72
|
+
fail_plan("Inventory contains target ${target} with unsupported transport, must be ssh or winrm")
|
73
|
+
}
|
19
74
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
75
|
+
|
76
|
+
# Bolt defaults to using the "module" based form of the puppet_agent plugin. Connect defaults
|
77
|
+
# to using the "task" based form as *only* the task based form in supported in Connect. This check
|
78
|
+
# ensures that if the default is not being used, only task based plugins are allowed.
|
79
|
+
$plugin = $target.plugin_hooks["puppet_library"]
|
80
|
+
$user_configured_plugin = $plugin != { "plugin"=> "puppet_agent", "stop_service"=> true }
|
81
|
+
if ($user_configured_plugin and $plugin["plugin"] != "task"){
|
82
|
+
fail_plan("Only task plugins are acceptable for puppet_library hook")
|
25
83
|
}
|
26
84
|
}
|
27
85
|
# The SSH/WinRM transports will report an 'unknown host' error for targets where
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bolt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -398,6 +398,7 @@ extra_rdoc_files: []
|
|
398
398
|
files:
|
399
399
|
- Puppetfile
|
400
400
|
- bolt-modules/boltlib/lib/puppet/datatypes/applyresult.rb
|
401
|
+
- bolt-modules/boltlib/lib/puppet/datatypes/containerresult.rb
|
401
402
|
- bolt-modules/boltlib/lib/puppet/datatypes/resourceinstance.rb
|
402
403
|
- bolt-modules/boltlib/lib/puppet/datatypes/result.rb
|
403
404
|
- bolt-modules/boltlib/lib/puppet/datatypes/resultset.rb
|
@@ -419,6 +420,7 @@ files:
|
|
419
420
|
- bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
|
420
421
|
- bolt-modules/boltlib/lib/puppet/functions/resource.rb
|
421
422
|
- bolt-modules/boltlib/lib/puppet/functions/run_command.rb
|
423
|
+
- bolt-modules/boltlib/lib/puppet/functions/run_container.rb
|
422
424
|
- bolt-modules/boltlib/lib/puppet/functions/run_plan.rb
|
423
425
|
- bolt-modules/boltlib/lib/puppet/functions/run_script.rb
|
424
426
|
- bolt-modules/boltlib/lib/puppet/functions/run_task.rb
|
@@ -444,6 +446,7 @@ files:
|
|
444
446
|
- bolt-modules/file/lib/puppet/functions/file/write.rb
|
445
447
|
- bolt-modules/out/lib/puppet/functions/out/message.rb
|
446
448
|
- bolt-modules/prompt/lib/puppet/functions/prompt.rb
|
449
|
+
- bolt-modules/prompt/lib/puppet/functions/prompt/menu.rb
|
447
450
|
- bolt-modules/system/lib/puppet/functions/system/env.rb
|
448
451
|
- exe/bolt
|
449
452
|
- guides/inventory.txt
|
@@ -467,11 +470,14 @@ files:
|
|
467
470
|
- lib/bolt/config/transport/base.rb
|
468
471
|
- lib/bolt/config/transport/docker.rb
|
469
472
|
- lib/bolt/config/transport/local.rb
|
473
|
+
- lib/bolt/config/transport/lxd.rb
|
470
474
|
- lib/bolt/config/transport/options.rb
|
471
475
|
- lib/bolt/config/transport/orch.rb
|
476
|
+
- lib/bolt/config/transport/podman.rb
|
472
477
|
- lib/bolt/config/transport/remote.rb
|
473
478
|
- lib/bolt/config/transport/ssh.rb
|
474
479
|
- lib/bolt/config/transport/winrm.rb
|
480
|
+
- lib/bolt/container_result.rb
|
475
481
|
- lib/bolt/error.rb
|
476
482
|
- lib/bolt/executor.rb
|
477
483
|
- lib/bolt/inventory.rb
|
@@ -555,8 +561,12 @@ files:
|
|
555
561
|
- lib/bolt/transport/docker/connection.rb
|
556
562
|
- lib/bolt/transport/local.rb
|
557
563
|
- lib/bolt/transport/local/connection.rb
|
564
|
+
- lib/bolt/transport/lxd.rb
|
565
|
+
- lib/bolt/transport/lxd/connection.rb
|
558
566
|
- lib/bolt/transport/orch.rb
|
559
567
|
- lib/bolt/transport/orch/connection.rb
|
568
|
+
- lib/bolt/transport/podman.rb
|
569
|
+
- lib/bolt/transport/podman/connection.rb
|
560
570
|
- lib/bolt/transport/remote.rb
|
561
571
|
- lib/bolt/transport/simple.rb
|
562
572
|
- lib/bolt/transport/ssh.rb
|