bolt 2.44.0 → 3.4.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 +11 -9
- data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +1 -1
- data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +25 -0
- data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +20 -2
- 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/lib/puppet/functions/wait_until_available.rb +7 -3
- 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/apply_result.rb +1 -1
- data/lib/bolt/bolt_option_parser.rb +9 -123
- data/lib/bolt/cli.rb +125 -127
- data/lib/bolt/config.rb +39 -214
- data/lib/bolt/config/options.rb +34 -125
- data/lib/bolt/config/transport/local.rb +1 -0
- data/lib/bolt/config/transport/lxd.rb +23 -0
- data/lib/bolt/config/transport/options.rb +9 -2
- data/lib/bolt/executor.rb +20 -5
- data/lib/bolt/logger.rb +9 -1
- 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 +52 -24
- data/lib/bolt/outputter/json.rb +16 -16
- data/lib/bolt/pal.rb +26 -5
- data/lib/bolt/pal/yaml_plan.rb +1 -2
- data/lib/bolt/pal/yaml_plan/evaluator.rb +5 -153
- data/lib/bolt/pal/yaml_plan/step.rb +91 -52
- 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/module.rb +0 -23
- data/lib/bolt/plugin/puppet_connect_data.rb +45 -3
- data/lib/bolt/project.rb +16 -56
- data/lib/bolt/project_manager.rb +5 -4
- data/lib/bolt/project_manager/module_migrator.rb +7 -6
- data/lib/bolt/result.rb +10 -11
- 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 +35 -14
- data/lib/bolt/shell/powershell/snippets.rb +37 -150
- data/lib/bolt/task.rb +1 -1
- data/lib/bolt/transport/base.rb +0 -9
- data/lib/bolt/transport/docker.rb +1 -125
- data/lib/bolt/transport/docker/connection.rb +86 -161
- data/lib/bolt/transport/local.rb +1 -9
- 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/ssh/connection.rb +1 -1
- data/lib/bolt/transport/winrm/connection.rb +1 -1
- data/lib/bolt/util.rb +8 -0
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/transport_app.rb +61 -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 +4 -0
- data/modules/aggregate/plans/count.pp +21 -0
- data/modules/aggregate/plans/targets.pp +21 -0
- data/modules/puppet_connect/plans/test_input_data.pp +67 -0
- data/modules/puppetdb_fact/plans/init.pp +10 -0
- metadata +7 -3
- data/modules/aggregate/plans/nodes.pp +0 -36
@@ -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
|
@@ -214,8 +214,12 @@ module BoltSpec
|
|
214
214
|
|
215
215
|
def report_bundled_content(_mode, _name); end
|
216
216
|
|
217
|
+
def report_file_source(_plan_function, _source); end
|
218
|
+
|
217
219
|
def report_apply(_statements, _resources); end
|
218
220
|
|
221
|
+
def report_yaml_plan(_plan); end
|
222
|
+
|
219
223
|
def publish_event(event)
|
220
224
|
if event[:type] == :message
|
221
225
|
unless @stub_out_message
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# @summary
|
2
|
+
# Run a task, command, or script on targets and aggregate the results as
|
3
|
+
# a count of targets for each value of a key.
|
4
|
+
#
|
5
|
+
# This plan accepts an action and a list of targets. The action can be the name
|
6
|
+
# of a task, a script, or a command to run. It will run the action on the
|
7
|
+
# targets and aggregate the key/value pairs in each Result into a hash, mapping
|
8
|
+
# the keys to a hash of each distinct value and how many targets returned that
|
9
|
+
# value for the key.
|
10
|
+
#
|
11
|
+
# @param command
|
12
|
+
# The command to run. Mutually exclusive with script and task.
|
13
|
+
# @param script
|
14
|
+
# The path to the script to run. Mutually exclusive with command and task.
|
15
|
+
# @param task
|
16
|
+
# The name of the task to run. Mutually exclusive with command and script.
|
17
|
+
# @param targets
|
18
|
+
# The list of targets to run the action on.
|
19
|
+
# @param params
|
20
|
+
# A hash of parameters and options to pass to the `run_*` function
|
21
|
+
# associated with the action (e.g. run_task).
|
1
22
|
plan aggregate::count(
|
2
23
|
Optional[String[0]] $task = undef,
|
3
24
|
Optional[String[0]] $command = undef,
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# @summary
|
2
|
+
# Run a task, command, or script on targets and aggregate the results as
|
3
|
+
# the list of targets for each value of a key in the results.
|
4
|
+
#
|
5
|
+
# This plan accepts an action and a list of targets. The action can be the name
|
6
|
+
# of a task, a script, or a command to run. It will run the action on the
|
7
|
+
# targets and aggregate the key/value pairs in each Result into a hash, mapping
|
8
|
+
# the keys to a hash of each distinct value and a list of targets returning that
|
9
|
+
# value.
|
10
|
+
#
|
11
|
+
# @param command
|
12
|
+
# The command to run. Mutually exclusive with script and task.
|
13
|
+
# @param script
|
14
|
+
# The path to the script to run. Mutually exclusive with command and task.
|
15
|
+
# @param task
|
16
|
+
# The name of the task to run. Mutually exclusive with command and script.
|
17
|
+
# @param targets
|
18
|
+
# The list of targets to run the action on.
|
19
|
+
# @param params
|
20
|
+
# A hash of parameters and options to pass to the `run_*` function
|
21
|
+
# associated with the action (e.g. run_task).
|
1
22
|
plan aggregate::targets(
|
2
23
|
Optional[String[0]] $task = undef,
|
3
24
|
Optional[String[0]] $command = undef,
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# @summary
|
2
|
+
# Tests that the provided Puppet Connect input data is complete, meaning that all consuming inventory targets are connectable.
|
3
|
+
#
|
4
|
+
# This plan should only be used as part of the copy-pastable "test input data"
|
5
|
+
# workflow specified in the Puppet Connect docs.
|
6
|
+
#
|
7
|
+
# @param targets
|
8
|
+
# The set of targets to test. Usually this should be 'all', the default.
|
9
|
+
#
|
10
|
+
# @return ResultSet the result of invoking the 'is connectable?' query on all
|
11
|
+
# the targets. Note that this query currently consists of running the 'echo'
|
12
|
+
# command.
|
13
|
+
#
|
14
|
+
plan puppet_connect::test_input_data(TargetSpec $targets = 'all') {
|
15
|
+
$targs = get_targets($targets)
|
16
|
+
$targs.each |$target| {
|
17
|
+
case $target.transport {
|
18
|
+
'ssh': {
|
19
|
+
$private_key_config = dig($target.config, 'ssh', 'private-key')
|
20
|
+
if $private_key_config =~ String {
|
21
|
+
$msg = @("END")
|
22
|
+
The SSH private key of the ${$target} target points to a filepath on disk,
|
23
|
+
which is not allowed in Puppet Connect. Instead, the private key contents must
|
24
|
+
be specified and this should be done via the PuppetConnectData plugin. Below is
|
25
|
+
an example of a Puppet Connect-compatible specification of the private-key. First,
|
26
|
+
we start with the inventory file:
|
27
|
+
...
|
28
|
+
private-key:
|
29
|
+
_plugin: puppet_connect_data
|
30
|
+
key: ssh_private_key
|
31
|
+
...
|
32
|
+
|
33
|
+
Next is the corresponding entry in the input data file:
|
34
|
+
...
|
35
|
+
ssh_private_key:
|
36
|
+
key-data:
|
37
|
+
<private_key_contents>
|
38
|
+
...
|
39
|
+
| END
|
40
|
+
|
41
|
+
out::message($msg)
|
42
|
+
fail_plan("The SSH private key of the ${$target} target points to a filepath on disk")
|
43
|
+
}
|
44
|
+
|
45
|
+
# Disable SSH autoloading to prevent false positive results
|
46
|
+
# (input data is wrong but target is still connectable due
|
47
|
+
# to autoloaded config)
|
48
|
+
set_config($target, ['ssh', 'load-config'], false)
|
49
|
+
# Maintain configuration parity with Puppet Connect to improve
|
50
|
+
# the reliability of our test
|
51
|
+
set_config($target, ['ssh', 'host-key-check'], false)
|
52
|
+
}
|
53
|
+
'winrm': {
|
54
|
+
# Maintain configuration parity with Puppet Connect
|
55
|
+
set_config($target, ['winrm', 'ssl'], false)
|
56
|
+
set_config($target, ['winrm', 'ssl-verify'], false)
|
57
|
+
}
|
58
|
+
default: {
|
59
|
+
fail_plan("Inventory contains target ${target} with unsupported transport, must be ssh or winrm")
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
# The SSH/WinRM transports will report an 'unknown host' error for targets where
|
64
|
+
# 'host' is unknown so run_command's implementation will take care of raising that
|
65
|
+
# error for us.
|
66
|
+
return run_command('echo Connected', $targs)
|
67
|
+
}
|
@@ -1,3 +1,13 @@
|
|
1
|
+
# @summary
|
2
|
+
# Collect facts for the specified targets from PuppetDB and store them
|
3
|
+
# on the Targets.
|
4
|
+
#
|
5
|
+
# This plan accepts a list of targets to collect facts for from the configured
|
6
|
+
# PuppetDB connection. After collecting facts, they are stored on each target's
|
7
|
+
# Target object. The updated facts can then be accessed using `$target.facts`.
|
8
|
+
#
|
9
|
+
# @param targets
|
10
|
+
# The targets to collect facts for.
|
1
11
|
plan puppetdb_fact(TargetSpec $targets) {
|
2
12
|
$targs = get_targets($targets)
|
3
13
|
$certnames = $targs.map |$target| { $target.host }
|
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:
|
4
|
+
version: 3.4.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-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -444,6 +444,7 @@ files:
|
|
444
444
|
- bolt-modules/file/lib/puppet/functions/file/write.rb
|
445
445
|
- bolt-modules/out/lib/puppet/functions/out/message.rb
|
446
446
|
- bolt-modules/prompt/lib/puppet/functions/prompt.rb
|
447
|
+
- bolt-modules/prompt/lib/puppet/functions/prompt/menu.rb
|
447
448
|
- bolt-modules/system/lib/puppet/functions/system/env.rb
|
448
449
|
- exe/bolt
|
449
450
|
- guides/inventory.txt
|
@@ -467,6 +468,7 @@ files:
|
|
467
468
|
- lib/bolt/config/transport/base.rb
|
468
469
|
- lib/bolt/config/transport/docker.rb
|
469
470
|
- lib/bolt/config/transport/local.rb
|
471
|
+
- lib/bolt/config/transport/lxd.rb
|
470
472
|
- lib/bolt/config/transport/options.rb
|
471
473
|
- lib/bolt/config/transport/orch.rb
|
472
474
|
- lib/bolt/config/transport/remote.rb
|
@@ -555,6 +557,8 @@ files:
|
|
555
557
|
- lib/bolt/transport/docker/connection.rb
|
556
558
|
- lib/bolt/transport/local.rb
|
557
559
|
- lib/bolt/transport/local/connection.rb
|
560
|
+
- lib/bolt/transport/lxd.rb
|
561
|
+
- lib/bolt/transport/lxd/connection.rb
|
558
562
|
- lib/bolt/transport/orch.rb
|
559
563
|
- lib/bolt/transport/orch/connection.rb
|
560
564
|
- lib/bolt/transport/remote.rb
|
@@ -609,12 +613,12 @@ files:
|
|
609
613
|
- modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
|
610
614
|
- modules/aggregate/lib/puppet/functions/aggregate/targets.rb
|
611
615
|
- modules/aggregate/plans/count.pp
|
612
|
-
- modules/aggregate/plans/nodes.pp
|
613
616
|
- modules/aggregate/plans/targets.pp
|
614
617
|
- modules/canary/lib/puppet/functions/canary/merge.rb
|
615
618
|
- modules/canary/lib/puppet/functions/canary/random_split.rb
|
616
619
|
- modules/canary/lib/puppet/functions/canary/skip.rb
|
617
620
|
- modules/canary/plans/init.pp
|
621
|
+
- modules/puppet_connect/plans/test_input_data.pp
|
618
622
|
- modules/puppetdb_fact/plans/init.pp
|
619
623
|
homepage: https://github.com/puppetlabs/bolt
|
620
624
|
licenses:
|
@@ -1,36 +0,0 @@
|
|
1
|
-
plan aggregate::nodes(
|
2
|
-
Optional[String[0]] $task = undef,
|
3
|
-
Optional[String[0]] $command = undef,
|
4
|
-
Optional[String[0]] $script = undef,
|
5
|
-
TargetSpec $nodes,
|
6
|
-
Hash[String, Data] $params = {}
|
7
|
-
) {
|
8
|
-
|
9
|
-
# Validation
|
10
|
-
$type_count = [$task, $command, $script].reduce(0) |$acc, $v| {
|
11
|
-
if ($v) {
|
12
|
-
$acc + 1
|
13
|
-
} else {
|
14
|
-
$acc
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
if ($type_count == 0) {
|
19
|
-
fail_plan("Must specify a command, script, or task to run", 'aggregate/invalid-params')
|
20
|
-
}
|
21
|
-
|
22
|
-
if ($type_count > 1) {
|
23
|
-
fail_plan("Must specify only one command, script, or task to run", 'aggregate/invalid-params')
|
24
|
-
}
|
25
|
-
|
26
|
-
$res = if ($task) {
|
27
|
-
run_task($task, $nodes, $params)
|
28
|
-
} elsif ($command) {
|
29
|
-
run_command($command, $nodes, $params)
|
30
|
-
} elsif ($script) {
|
31
|
-
run_script($script, $nodes, $params)
|
32
|
-
}
|
33
|
-
|
34
|
-
return aggregate::nodes($res)
|
35
|
-
}
|
36
|
-
|