bolt 2.42.0 → 3.3.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 +21 -19
- 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/parallelize.rb +6 -8
- data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +2 -2
- data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +27 -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/lib/bolt/analytics.rb +3 -2
- data/lib/bolt/applicator.rb +11 -1
- data/lib/bolt/apply_result.rb +1 -1
- data/lib/bolt/bolt_option_parser.rb +9 -116
- data/lib/bolt/catalog.rb +10 -29
- data/lib/bolt/cli.rb +90 -154
- data/lib/bolt/config.rb +66 -239
- data/lib/bolt/config/options.rb +79 -102
- data/lib/bolt/config/transport/local.rb +1 -0
- data/lib/bolt/config/transport/lxd.rb +21 -0
- data/lib/bolt/config/transport/options.rb +9 -2
- data/lib/bolt/config/transport/orch.rb +1 -0
- data/lib/bolt/executor.rb +23 -6
- data/lib/bolt/inventory.rb +1 -1
- data/lib/bolt/inventory/group.rb +7 -4
- data/lib/bolt/logger.rb +123 -11
- data/lib/bolt/module_installer.rb +6 -4
- data/lib/bolt/module_installer/puppetfile.rb +2 -2
- data/lib/bolt/module_installer/resolver.rb +59 -14
- data/lib/bolt/module_installer/specs/forge_spec.rb +10 -4
- data/lib/bolt/module_installer/specs/git_spec.rb +19 -4
- data/lib/bolt/outputter/human.rb +56 -17
- data/lib/bolt/outputter/json.rb +16 -16
- data/lib/bolt/outputter/rainbow.rb +3 -3
- data/lib/bolt/pal.rb +95 -15
- data/lib/bolt/pal/yaml_plan.rb +9 -4
- 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 +16 -16
- 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 +32 -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 +2 -1
- data/lib/bolt/plan_creator.rb +1 -1
- data/lib/bolt/plugin.rb +2 -2
- data/lib/bolt/plugin/cache.rb +7 -7
- data/lib/bolt/plugin/module.rb +0 -23
- data/lib/bolt/plugin/puppet_connect_data.rb +77 -0
- data/lib/bolt/plugin/puppetdb.rb +1 -1
- data/lib/bolt/project.rb +54 -81
- data/lib/bolt/project_manager.rb +5 -4
- data/lib/bolt/project_manager/module_migrator.rb +7 -6
- data/lib/bolt/rerun.rb +1 -1
- data/lib/bolt/result.rb +6 -1
- data/lib/bolt/shell.rb +16 -0
- data/lib/bolt/shell/bash.rb +57 -25
- data/lib/bolt/shell/bash/tmpdir.rb +6 -3
- data/lib/bolt/shell/powershell.rb +33 -10
- data/lib/bolt/shell/powershell/snippets.rb +37 -150
- data/lib/bolt/task.rb +2 -2
- 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/connection.rb +1 -1
- data/lib/bolt/transport/ssh.rb +1 -2
- data/lib/bolt/transport/ssh/connection.rb +2 -2
- data/lib/bolt/transport/winrm/connection.rb +1 -1
- data/lib/bolt/validator.rb +2 -2
- data/lib/bolt/version.rb +1 -1
- data/lib/bolt_server/config.rb +1 -1
- data/lib/bolt_server/transport_app.rb +61 -32
- 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/mock_executor.rb +4 -0
- data/libexec/bolt_catalog +1 -1
- 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 +13 -9
- data/modules/aggregate/plans/nodes.pp +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e32573bc97fea7eca64b7c915cb4b462e1325fb5d4dcbe95c48c72aae8c0e14
|
4
|
+
data.tar.gz: abb279c5a363092ca37ddf4eac9de665de9f79aa74c9e0af9697910b336b7b93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23bf7042750c180eb618eaafd8af34e014deb5c7ab0dadcce316e92c3aa66e62ae85e89e96f471cc54f17c81eba463f73b776e9aa4581219567ed15876722967
|
7
|
+
data.tar.gz: bcd1eb6192f5ac92959088edfbe7b333dcb9ed63f6da7a36a6274d72cbce32e77f4f01a8427edec78be3dd9caeab2472ec3691d846108367df407187606ba2ae
|
data/Puppetfile
CHANGED
@@ -5,14 +5,14 @@ forge "http://forge.puppetlabs.com"
|
|
5
5
|
moduledir File.join(File.dirname(__FILE__), 'modules')
|
6
6
|
|
7
7
|
# Core modules used by 'apply'
|
8
|
-
mod 'puppetlabs-service', '
|
9
|
-
mod 'puppetlabs-puppet_agent', '4.
|
10
|
-
mod 'puppetlabs-facts', '1.
|
8
|
+
mod 'puppetlabs-service', '2.0.0'
|
9
|
+
mod 'puppetlabs-puppet_agent', '4.4.0'
|
10
|
+
mod 'puppetlabs-facts', '1.4.0'
|
11
11
|
|
12
12
|
# Core types and providers for Puppet 6
|
13
|
-
mod 'puppetlabs-augeas_core', '1.1.
|
13
|
+
mod 'puppetlabs-augeas_core', '1.1.2'
|
14
14
|
mod 'puppetlabs-host_core', '1.0.3'
|
15
|
-
mod 'puppetlabs-scheduled_task', '
|
15
|
+
mod 'puppetlabs-scheduled_task', '3.0.0'
|
16
16
|
mod 'puppetlabs-sshkeys_core', '2.2.0'
|
17
17
|
mod 'puppetlabs-zfs_core', '1.2.0'
|
18
18
|
mod 'puppetlabs-cron_core', '1.0.5'
|
@@ -22,26 +22,28 @@ mod 'puppetlabs-yumrepo_core', '1.0.7'
|
|
22
22
|
mod 'puppetlabs-zone_core', '1.0.3'
|
23
23
|
|
24
24
|
# Useful additional modules
|
25
|
-
mod 'puppetlabs-package', '
|
26
|
-
mod 'puppetlabs-
|
27
|
-
mod 'puppetlabs-
|
28
|
-
mod 'puppetlabs-
|
29
|
-
mod 'puppetlabs-
|
30
|
-
mod 'puppetlabs-
|
31
|
-
mod 'puppetlabs-
|
25
|
+
mod 'puppetlabs-package', '2.0.0'
|
26
|
+
mod 'puppetlabs-powershell_task_helper', '0.1.0'
|
27
|
+
mod 'puppetlabs-puppet_conf', '1.0.0'
|
28
|
+
mod 'puppetlabs-python_task_helper', '0.5.0'
|
29
|
+
mod 'puppetlabs-reboot', '4.0.0'
|
30
|
+
mod 'puppetlabs-ruby_task_helper', '0.6.0'
|
31
|
+
mod 'puppetlabs-ruby_plugin_helper', '0.2.0'
|
32
|
+
mod 'puppetlabs-stdlib', '7.0.0'
|
32
33
|
|
33
34
|
# Plugin modules
|
34
|
-
mod 'puppetlabs-aws_inventory', '0.
|
35
|
-
mod 'puppetlabs-azure_inventory', '0.
|
36
|
-
mod 'puppetlabs-gcloud_inventory', '0.
|
37
|
-
mod 'puppetlabs-http_request', '0.2.
|
35
|
+
mod 'puppetlabs-aws_inventory', '0.6.0'
|
36
|
+
mod 'puppetlabs-azure_inventory', '0.5.0'
|
37
|
+
mod 'puppetlabs-gcloud_inventory', '0.2.0'
|
38
|
+
mod 'puppetlabs-http_request', '0.2.2'
|
38
39
|
mod 'puppetlabs-pkcs7', '0.1.1'
|
39
|
-
mod 'puppetlabs-secure_env_vars', '0.
|
40
|
-
mod 'puppetlabs-terraform', '0.
|
41
|
-
mod 'puppetlabs-vault', '0.
|
40
|
+
mod 'puppetlabs-secure_env_vars', '0.2.0'
|
41
|
+
mod 'puppetlabs-terraform', '0.6.1'
|
42
|
+
mod 'puppetlabs-vault', '0.4.0'
|
42
43
|
mod 'puppetlabs-yaml', '0.2.0'
|
43
44
|
|
44
45
|
# If we don't list these modules explicitly, r10k will purge them
|
45
46
|
mod 'canary', local: true
|
46
47
|
mod 'aggregate', local: true
|
47
48
|
mod 'puppetdb_fact', local: true
|
49
|
+
mod 'puppet_connect', local: true
|
@@ -7,7 +7,7 @@ require 'bolt/error'
|
|
7
7
|
# > **Note:** Not available in apply block
|
8
8
|
Puppet::Functions.create_function(:add_facts) do
|
9
9
|
# @param target A target.
|
10
|
-
# @param facts A hash of fact names to values that
|
10
|
+
# @param facts A hash of fact names to values that can include structured facts.
|
11
11
|
# @return A `Target` object.
|
12
12
|
# @example Adding facts to a target
|
13
13
|
# add_facts($target, { 'os' => { 'family' => 'windows', 'name' => 'windows' } })
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'bolt/logger'
|
3
4
|
require 'bolt/task'
|
4
5
|
|
5
6
|
# Installs the `puppet-agent` package on targets if needed, then collects facts,
|
@@ -131,10 +132,20 @@ Puppet::Functions.create_function(:apply_prep) do
|
|
131
132
|
task = applicator.custom_facts_task
|
132
133
|
arguments = { 'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins) }
|
133
134
|
results = executor.run_task(targets, task, arguments)
|
135
|
+
|
134
136
|
# TODO: Standardize RunFailure type with error above
|
135
137
|
raise Bolt::RunFailure.new(results, 'run_task', task.name) unless results.ok?
|
136
138
|
|
137
139
|
results.each do |result|
|
140
|
+
# Log a warning if the client version is < 6
|
141
|
+
if unsupported_puppet?(result['clientversion'])
|
142
|
+
Bolt::Logger.deprecate(
|
143
|
+
"unsupported_puppet",
|
144
|
+
"Detected unsupported Puppet agent version #{result['clientversion']} on target "\
|
145
|
+
"#{result.target}. Bolt supports Puppet agent 6.0.0 and higher."
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
138
149
|
inventory.add_facts(result.target, result.value)
|
139
150
|
end
|
140
151
|
end
|
@@ -143,4 +154,18 @@ Puppet::Functions.create_function(:apply_prep) do
|
|
143
154
|
# Return nothing
|
144
155
|
nil
|
145
156
|
end
|
157
|
+
|
158
|
+
# Returns true if the client's major version is < 6.
|
159
|
+
#
|
160
|
+
private def unsupported_puppet?(client_version)
|
161
|
+
if client_version.nil?
|
162
|
+
false
|
163
|
+
else
|
164
|
+
begin
|
165
|
+
Integer(client_version.split('.').first) < 6
|
166
|
+
rescue StandardError
|
167
|
+
false
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
146
171
|
end
|
@@ -12,14 +12,12 @@ Puppet::Functions.create_function(:parallelize, Puppet::Functions::InternalFunct
|
|
12
12
|
# @param data The array to apply the block to.
|
13
13
|
# @return [Array] An array of PlanResult objects. Each input from the input
|
14
14
|
# array returns a corresponding PlanResult object.
|
15
|
-
# @example Execute two tasks on
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# $
|
20
|
-
#
|
21
|
-
# run_task('b', $t)
|
22
|
-
# }
|
15
|
+
# @example Execute two tasks on two targets.
|
16
|
+
# $targets = get_targets(["host1", "host2"])
|
17
|
+
# $result = parallelize ($targets) |$t| {
|
18
|
+
# run_task('a', $t)
|
19
|
+
# run_task('b', $t)
|
20
|
+
# }
|
23
21
|
dispatch :parallelize do
|
24
22
|
scope_param
|
25
23
|
param 'Array[Any]', :data
|
@@ -256,7 +256,7 @@ Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction
|
|
256
256
|
if nodes_param
|
257
257
|
if params['nodes']
|
258
258
|
raise ArgumentError,
|
259
|
-
"A plan's 'nodes' parameter
|
259
|
+
"A plan's 'nodes' parameter can be specified as the second positional argument to " \
|
260
260
|
"run_plan(), but in that case 'nodes' must not be specified in the named arguments " \
|
261
261
|
"hash."
|
262
262
|
end
|
@@ -265,7 +265,7 @@ Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction
|
|
265
265
|
elsif targets_param
|
266
266
|
if params['targets']
|
267
267
|
raise ArgumentError,
|
268
|
-
"A plan's 'targets' parameter
|
268
|
+
"A plan's 'targets' parameter can be specified as the second positional argument to " \
|
269
269
|
"run_plan(), but in that case 'targets' must not be specified in the named arguments " \
|
270
270
|
"hash."
|
271
271
|
end
|
@@ -6,19 +6,24 @@
|
|
6
6
|
# > **Note:** Not available in apply block
|
7
7
|
Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFunction) do
|
8
8
|
# Run a script.
|
9
|
-
# @param script Path to a script to run on target.
|
9
|
+
# @param script Path to a script to run on target. Can be an absolute path or a modulename/filename selector for a
|
10
10
|
# file in $MODULEROOT/files.
|
11
11
|
# @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
|
12
12
|
# @param options A hash of additional options.
|
13
13
|
# @option options [Array[String]] arguments An array of arguments to be passed to the script.
|
14
|
+
# Cannot be used with `pwsh_params`.
|
15
|
+
# @option options [Hash] pwsh_params Map of named parameters to pass to a PowerShell script.
|
16
|
+
# Cannot be used with `arguments`.
|
14
17
|
# @option options [Boolean] _catch_errors Whether to catch raised errors.
|
15
18
|
# @option options [String] _run_as User to run as using privilege escalation.
|
16
|
-
# @option options [Hash] _env_vars Map of environment variables to set
|
19
|
+
# @option options [Hash] _env_vars Map of environment variables to set.
|
17
20
|
# @return A list of results, one entry per target.
|
18
21
|
# @example Run a local script on Linux targets as 'root'
|
19
22
|
# run_script('/var/tmp/myscript', $targets, '_run_as' => 'root')
|
20
23
|
# @example Run a module-provided script with arguments
|
21
24
|
# run_script('iis/setup.ps1', $target, 'arguments' => ['/u', 'Administrator'])
|
25
|
+
# @example Pass named parameters to a PowerShell script
|
26
|
+
# run_script('iis/setup.ps1', $target, 'pwsh_params' => { 'User' => 'Administrator' })
|
22
27
|
dispatch :run_script do
|
23
28
|
scope_param
|
24
29
|
param 'String[1]', :script
|
@@ -28,15 +33,18 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
|
|
28
33
|
end
|
29
34
|
|
30
35
|
# Run a script, logging the provided description.
|
31
|
-
# @param script Path to a script to run on target.
|
36
|
+
# @param script Path to a script to run on target. Can be an absolute path or a modulename/filename selector for a
|
32
37
|
# file in $MODULEROOT/files.
|
33
38
|
# @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
|
34
39
|
# @param description A description to be output when calling this function.
|
35
40
|
# @param options A hash of additional options.
|
36
41
|
# @option options [Array[String]] arguments An array of arguments to be passed to the script.
|
42
|
+
# Cannot be used with `pwsh_params`.
|
43
|
+
# @option options [Hash] pwsh_params Map of named parameters to pass to a PowerShell script.
|
44
|
+
# Cannot be used with `arguments`.
|
37
45
|
# @option options [Boolean] _catch_errors Whether to catch raised errors.
|
38
46
|
# @option options [String] _run_as User to run as using privilege escalation.
|
39
|
-
# @option options [Hash] _env_vars Map of environment variables to set
|
47
|
+
# @option options [Hash] _env_vars Map of environment variables to set.
|
40
48
|
# @return A list of results, one entry per target.
|
41
49
|
# @example Run a script
|
42
50
|
# run_script('/var/tmp/myscript', $targets, 'Downloading my application')
|
@@ -59,9 +67,23 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
|
|
59
67
|
.from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'run_script')
|
60
68
|
end
|
61
69
|
|
70
|
+
if options.key?('arguments') && options.key?('pwsh_params')
|
71
|
+
raise Bolt::ValidationError, "Cannot specify both 'arguments' and 'pwsh_params'"
|
72
|
+
end
|
73
|
+
|
74
|
+
if options.key?('pwsh_params') && !options['pwsh_params'].is_a?(Hash)
|
75
|
+
raise Bolt::ValidationError, "Option 'pwsh_params' must be a hash"
|
76
|
+
end
|
77
|
+
|
78
|
+
if options.key?('arguments') && !options['arguments'].is_a?(Array)
|
79
|
+
raise Bolt::ValidationError, "Option 'arguments' must be an array"
|
80
|
+
end
|
81
|
+
|
62
82
|
arguments = options['arguments'] || []
|
83
|
+
pwsh_params = options['pwsh_params']
|
63
84
|
options = options.select { |opt| opt.start_with?('_') }.transform_keys { |k| k.sub(/^_/, '').to_sym }
|
64
85
|
options[:description] = description if description
|
86
|
+
options[:pwsh_params] = pwsh_params if pwsh_params
|
65
87
|
|
66
88
|
executor = Puppet.lookup(:bolt_executor)
|
67
89
|
inventory = Puppet.lookup(:bolt_inventory)
|
@@ -80,7 +102,7 @@ Puppet::Functions.create_function(:run_script, Puppet::Functions::InternalFuncti
|
|
80
102
|
Puppet::Pops::Issues::NOT_A_FILE, file: script
|
81
103
|
)
|
82
104
|
end
|
83
|
-
|
105
|
+
executor.report_file_source(self.class.name, script)
|
84
106
|
# Ensure that given targets are all Target instances)
|
85
107
|
targets = inventory.get_targets(targets)
|
86
108
|
|
@@ -76,7 +76,7 @@ Puppet::Functions.create_function(:upload_file, Puppet::Functions::InternalFunct
|
|
76
76
|
Puppet::Pops::Issues::NO_SUCH_FILE_OR_DIRECTORY, file: source
|
77
77
|
)
|
78
78
|
end
|
79
|
-
|
79
|
+
executor.report_file_source(self.class.name, source)
|
80
80
|
# Ensure that that given targets are all Target instances
|
81
81
|
targets = inventory.get_targets(targets)
|
82
82
|
if targets.empty?
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'bolt/util'
|
4
4
|
|
5
|
-
# Wait until all targets accept connections.
|
5
|
+
# Wait until all targets accept connections. This function allows a plan execution to wait for a customizable
|
6
|
+
# amount of time via the `wait_time` option until a target connection can be reestablished. The plan proceeds
|
7
|
+
# to the next step if the connection fails to reconnect in the time specified (default: 120 seconds). A typical
|
8
|
+
# use case for this function is if your plan reboots a remote host and the plan needs to wait for the host to reconnect
|
9
|
+
# before it continues to the next step.
|
6
10
|
#
|
7
11
|
# > **Note:** Not available in apply block
|
8
12
|
Puppet::Functions.create_function(:wait_until_available) do
|
@@ -10,8 +14,8 @@ Puppet::Functions.create_function(:wait_until_available) do
|
|
10
14
|
# @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
|
11
15
|
# @param options A hash of additional options.
|
12
16
|
# @option options [String] description A description for logging. (default: 'wait until available')
|
13
|
-
# @option options [Numeric] wait_time The time to wait. (default: 120)
|
14
|
-
# @option options [Numeric] retry_interval The interval to wait before retrying. (default: 1)
|
17
|
+
# @option options [Numeric] wait_time The time to wait, in seconds. (default: 120)
|
18
|
+
# @option options [Numeric] retry_interval The interval to wait before retrying, in seconds. (default: 1)
|
15
19
|
# @option options [Boolean] _catch_errors Whether to catch raised errors.
|
16
20
|
# @return A list of results, one entry per target. Successful results have no value.
|
17
21
|
# @example Wait for targets
|
@@ -17,7 +17,8 @@ Puppet::Functions.create_function(:'file::read', Puppet::Functions::InternalFunc
|
|
17
17
|
|
18
18
|
def read(scope, filename)
|
19
19
|
# Send Analytics Report
|
20
|
-
Puppet.lookup(:bolt_executor) {}
|
20
|
+
executor = Puppet.lookup(:bolt_executor) {}
|
21
|
+
executor&.report_function_call(self.class.name)
|
21
22
|
|
22
23
|
found = Puppet::Parser::Files.find_file(filename, scope.compiler.environment)
|
23
24
|
unless found && Puppet::FileSystem.exist?(found)
|
@@ -25,7 +26,7 @@ Puppet::Functions.create_function(:'file::read', Puppet::Functions::InternalFunc
|
|
25
26
|
Puppet::Pops::Issues::NO_SUCH_FILE_OR_DIRECTORY, file: filename
|
26
27
|
)
|
27
28
|
end
|
28
|
-
|
29
|
+
executor&.report_file_source(self.class.name, filename)
|
29
30
|
File.read(found)
|
30
31
|
end
|
31
32
|
end
|
data/lib/bolt/analytics.rb
CHANGED
@@ -78,7 +78,7 @@ module Bolt
|
|
78
78
|
Bolt::Util.read_optional_yaml_hash(filename, 'analytics')
|
79
79
|
else
|
80
80
|
unless ENV['BOLT_DISABLE_ANALYTICS']
|
81
|
-
|
81
|
+
msg = <<~ANALYTICS
|
82
82
|
Bolt collects data about how you use it. You can opt out of providing this data.
|
83
83
|
|
84
84
|
To disable analytics data collection, add this line to ~/.puppetlabs/etc/bolt/analytics.yaml :
|
@@ -86,7 +86,8 @@ module Bolt
|
|
86
86
|
|
87
87
|
Read more about what data Bolt collects and why here:
|
88
88
|
https://puppet.com/docs/bolt/latest/bolt_installing.html#analytics-data-collection
|
89
|
-
|
89
|
+
ANALYTICS
|
90
|
+
Bolt::Logger.warn_once('analytics_opt_out', msg)
|
90
91
|
end
|
91
92
|
|
92
93
|
{}
|
data/lib/bolt/applicator.rb
CHANGED
@@ -125,7 +125,16 @@ module Bolt
|
|
125
125
|
@logger.send(bolt_level, "#{target.name}: #{message}")
|
126
126
|
end
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
|
+
unless stat.success?
|
130
|
+
message = if @apply_settings['trace'] && result['backtrace']
|
131
|
+
([result['message']] + result['backtrace']).join("\n ")
|
132
|
+
else
|
133
|
+
result['message']
|
134
|
+
end
|
135
|
+
raise ApplyError.new(target.name, message)
|
136
|
+
end
|
137
|
+
|
129
138
|
result
|
130
139
|
end
|
131
140
|
|
@@ -236,6 +245,7 @@ module Bolt
|
|
236
245
|
else
|
237
246
|
Bolt::ApplyError.new(batch_target, future.reason.message)
|
238
247
|
end
|
248
|
+
|
239
249
|
result = Bolt::ApplyResult.new(batch_target, error: error.to_h)
|
240
250
|
@executor.publish_event(type: :node_result, result: result)
|
241
251
|
result
|
data/lib/bolt/apply_result.rb
CHANGED
@@ -54,7 +54,7 @@ module Bolt
|
|
54
54
|
unless missing_keys.empty?
|
55
55
|
if result['_output']
|
56
56
|
# rubocop:disable Layout/LineLength
|
57
|
-
msg = "Report result contains an '_output' key. Catalog application
|
57
|
+
msg = "Report result contains an '_output' key. Catalog application might have printed extraneous output to stdout: #{result['_output']}"
|
58
58
|
# rubocop:enable Layout/LineLength
|
59
59
|
else
|
60
60
|
msg = "Report did not contain all expected keys missing: #{missing_keys.join(', ')}"
|
@@ -6,15 +6,15 @@ require 'optparse'
|
|
6
6
|
|
7
7
|
module Bolt
|
8
8
|
class BoltOptionParser < OptionParser
|
9
|
-
PROJECT_PATHS = %w[project
|
10
|
-
OPTIONS = { inventory: %w[targets query rerun
|
9
|
+
PROJECT_PATHS = %w[project].freeze
|
10
|
+
OPTIONS = { inventory: %w[targets query rerun],
|
11
11
|
authentication: %w[user password password-prompt private-key host-key-check ssl ssl-verify],
|
12
12
|
escalation: %w[run-as sudo-password sudo-password-prompt sudo-executable],
|
13
13
|
run_context: %w[concurrency inventoryfile save-rerun cleanup],
|
14
14
|
global_config_setters: PROJECT_PATHS + %w[modulepath],
|
15
15
|
transports: %w[transport connect-timeout tty native-ssh ssh-command copy-command],
|
16
|
-
display: %w[format color verbose trace],
|
17
|
-
global: %w[help version
|
16
|
+
display: %w[format color verbose trace stream],
|
17
|
+
global: %w[help version log-level clear-cache] }.freeze
|
18
18
|
|
19
19
|
ACTION_OPTS = OPTIONS.values.flatten.freeze
|
20
20
|
|
@@ -114,21 +114,6 @@ module Bolt
|
|
114
114
|
{ flags: OPTIONS[:global],
|
115
115
|
banner: PROJECT_HELP }
|
116
116
|
end
|
117
|
-
when 'puppetfile'
|
118
|
-
case action
|
119
|
-
when 'install'
|
120
|
-
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters] + %w[puppetfile],
|
121
|
-
banner: PUPPETFILE_INSTALL_HELP }
|
122
|
-
when 'show-modules'
|
123
|
-
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
|
124
|
-
banner: PUPPETFILE_SHOWMODULES_HELP }
|
125
|
-
when 'generate-types'
|
126
|
-
{ flags: OPTIONS[:global] + OPTIONS[:global_config_setters],
|
127
|
-
banner: PUPPETFILE_GENERATETYPES_HELP }
|
128
|
-
else
|
129
|
-
{ flags: OPTIONS[:global],
|
130
|
-
banner: PUPPETFILE_HELP }
|
131
|
-
end
|
132
117
|
when 'script'
|
133
118
|
case action
|
134
119
|
when 'run'
|
@@ -192,7 +177,6 @@ module Bolt
|
|
192
177
|
module Manage Bolt project modules
|
193
178
|
plan Convert, create, show, and run Bolt plans
|
194
179
|
project Create and migrate Bolt projects
|
195
|
-
puppetfile Install and list modules and generate type references
|
196
180
|
script Upload a local script and run it remotely
|
197
181
|
secret Create encryption keys and encrypt and decrypt values
|
198
182
|
task Show and run Bolt tasks
|
@@ -470,7 +454,7 @@ module Bolt
|
|
470
454
|
DESCRIPTION
|
471
455
|
Convert a YAML plan to a Puppet language plan and print the converted plan to stdout.
|
472
456
|
|
473
|
-
Converting a YAML plan
|
457
|
+
Converting a YAML plan might result in a plan that is syntactically
|
474
458
|
correct but has different behavior. Always verify a converted plan's
|
475
459
|
functionality. Note that the converted plan is not written to a file.
|
476
460
|
|
@@ -576,55 +560,6 @@ module Bolt
|
|
576
560
|
Migrate a Bolt project to use current best practices and the latest version of configuration files.
|
577
561
|
HELP
|
578
562
|
|
579
|
-
PUPPETFILE_HELP = <<~HELP
|
580
|
-
NAME
|
581
|
-
puppetfile
|
582
|
-
|
583
|
-
USAGE
|
584
|
-
bolt puppetfile <action> [options]
|
585
|
-
|
586
|
-
DESCRIPTION
|
587
|
-
Install and list modules and generate type references
|
588
|
-
|
589
|
-
ACTIONS
|
590
|
-
generate-types Generate type references to register in plans
|
591
|
-
install Install modules from a Puppetfile into a project
|
592
|
-
show-modules List modules available to the Bolt project
|
593
|
-
HELP
|
594
|
-
|
595
|
-
PUPPETFILE_GENERATETYPES_HELP = <<~HELP
|
596
|
-
NAME
|
597
|
-
generate-types
|
598
|
-
|
599
|
-
USAGE
|
600
|
-
bolt puppetfile generate-types [options]
|
601
|
-
|
602
|
-
DESCRIPTION
|
603
|
-
Generate type references to register in plans.
|
604
|
-
HELP
|
605
|
-
|
606
|
-
PUPPETFILE_INSTALL_HELP = <<~HELP
|
607
|
-
NAME
|
608
|
-
install
|
609
|
-
|
610
|
-
USAGE
|
611
|
-
bolt puppetfile install [options]
|
612
|
-
|
613
|
-
DESCRIPTION
|
614
|
-
Install modules from a Puppetfile into a project
|
615
|
-
HELP
|
616
|
-
|
617
|
-
PUPPETFILE_SHOWMODULES_HELP = <<~HELP
|
618
|
-
NAME
|
619
|
-
show-modules
|
620
|
-
|
621
|
-
USAGE
|
622
|
-
bolt puppetfile show-modules [options]
|
623
|
-
|
624
|
-
DESCRIPTION
|
625
|
-
List modules available to the Bolt project.
|
626
|
-
HELP
|
627
|
-
|
628
563
|
SCRIPT_HELP = <<~HELP
|
629
564
|
NAME
|
630
565
|
script
|
@@ -760,13 +695,10 @@ module Bolt
|
|
760
695
|
bolt task show canary
|
761
696
|
HELP
|
762
697
|
|
763
|
-
attr_reader :deprecations
|
764
|
-
|
765
698
|
def initialize(options)
|
766
699
|
super()
|
767
700
|
|
768
701
|
@options = options
|
769
|
-
@deprecations = []
|
770
702
|
|
771
703
|
separator "\nINVENTORY OPTIONS"
|
772
704
|
define('-t', '--targets TARGETS',
|
@@ -775,7 +707,7 @@ module Bolt
|
|
775
707
|
"Or read a target list from an input file '@<file>' or stdin '-'.",
|
776
708
|
'Example: --targets localhost,target_group,ssh://nix.com:23,winrm://windows.puppet.com',
|
777
709
|
'URI format is [protocol://]host[:port]',
|
778
|
-
"SSH is the default protocol;
|
710
|
+
"SSH is the default protocol; can be #{TRANSPORTS.keys.join(', ')}",
|
779
711
|
'For Windows targets, specify the winrm:// protocol if it has not be configured',
|
780
712
|
'For SSH, port defaults to `22`',
|
781
713
|
'For WinRM, port defaults to `5985` or `5986` based on the --[no-]ssl setting') do |targets|
|
@@ -794,13 +726,6 @@ module Bolt
|
|
794
726
|
define('--noop', 'See what changes Bolt will make without actually executing the changes') do |_|
|
795
727
|
@options[:noop] = true
|
796
728
|
end
|
797
|
-
define('--description DESCRIPTION',
|
798
|
-
'Deprecated. Description to use for the job') do |description|
|
799
|
-
msg = "Command line option '--description' is deprecated, and will be "\
|
800
|
-
"removed in Bolt 3.0."
|
801
|
-
@deprecations << { type: 'Using --description', msg: msg }
|
802
|
-
@options[:description] = description
|
803
|
-
end
|
804
729
|
define('--params PARAMETERS',
|
805
730
|
"Parameters to a task or plan as json, a json file '@<file>', or on stdin '-'") do |params|
|
806
731
|
@options[:task_options] = parse_params(params)
|
@@ -878,27 +803,10 @@ module Bolt
|
|
878
803
|
File.expand_path(moduledir)
|
879
804
|
end
|
880
805
|
end
|
881
|
-
define('--boltdir PATH',
|
882
|
-
'Deprecated. Specify what project to load config from (default:',
|
883
|
-
'autodiscovered from current working dir)') do |path|
|
884
|
-
msg = "Command line option '--boltdir' is deprecated, use '--project' instead."
|
885
|
-
@deprecations << { type: 'Using --boltdir', msg: msg }
|
886
|
-
@options[:boltdir] = path
|
887
|
-
end
|
888
806
|
define('--project PATH',
|
889
807
|
'Path to load the Bolt project from (default: autodiscovered from current dir)') do |path|
|
890
808
|
@options[:project] = path
|
891
809
|
end
|
892
|
-
define('--configfile PATH',
|
893
|
-
'Deprecated. Specify where to load config from (default:',
|
894
|
-
'~/.puppetlabs/bolt/bolt.yaml). Directory containing bolt.yaml will be',
|
895
|
-
'used as the project directory.') do |path|
|
896
|
-
msg = "Command line option '--configfile' is deprecated, and " \
|
897
|
-
"will be removed in Bolt 3.0. Use '--project' and provide the "\
|
898
|
-
"directory path instead."
|
899
|
-
@deprecations << { type: 'Using --configfile', msg: msg }
|
900
|
-
@options[:configfile] = path
|
901
|
-
end
|
902
810
|
define('--hiera-config PATH',
|
903
811
|
'Specify where to load Hiera config from (default: ~/.puppetlabs/bolt/hiera.yaml)') do |path|
|
904
812
|
@options[:'hiera-config'] = File.expand_path(path)
|
@@ -910,17 +818,6 @@ module Bolt
|
|
910
818
|
end
|
911
819
|
@options[:inventoryfile] = File.expand_path(path)
|
912
820
|
end
|
913
|
-
define('--puppetfile PATH',
|
914
|
-
'Deprecated. Specify a Puppetfile to use when installing modules.',
|
915
|
-
' (default: ~/.puppetlabs/bolt/Puppetfile)',
|
916
|
-
'Modules are installed in the current project.') do |path|
|
917
|
-
command = Bolt::Util.powershell? ? 'Update-BoltProject' : 'bolt project migrate'
|
918
|
-
msg = "Command line option '--puppetfile' is deprecated, and will be removed "\
|
919
|
-
"in Bolt 3.0. You can migrate to using the new module management "\
|
920
|
-
"workflow using '#{command}'."
|
921
|
-
@deprecations << { type: 'Using --puppetfile', msg: msg }
|
922
|
-
@options[:puppetfile_path] = File.expand_path(path)
|
923
|
-
end
|
924
821
|
define('--[no-]save-rerun', 'Whether to update the rerun file after this command.') do |save|
|
925
822
|
@options[:'save-rerun'] = save
|
926
823
|
end
|
@@ -991,6 +888,9 @@ module Bolt
|
|
991
888
|
define('-v', '--[no-]verbose', 'Display verbose logging') do |value|
|
992
889
|
@options[:verbose] = value
|
993
890
|
end
|
891
|
+
define('--stream', 'Stream output from scripts and commands to the console') do |_|
|
892
|
+
@options[:stream] = true
|
893
|
+
end
|
994
894
|
define('--trace', 'Display error stack traces') do |_|
|
995
895
|
@options[:trace] = true
|
996
896
|
end
|
@@ -1013,13 +913,6 @@ module Bolt
|
|
1013
913
|
puts Bolt::VERSION
|
1014
914
|
raise Bolt::CLIExit
|
1015
915
|
end
|
1016
|
-
define('--debug', 'Display debug logging') do |_|
|
1017
|
-
@options[:debug] = true
|
1018
|
-
# We don't actually set '--log-level debug' here, but once the options are evaluated by
|
1019
|
-
# the config class the end result is the same.
|
1020
|
-
msg = "Command line option '--debug' is deprecated, set '--log-level debug' instead."
|
1021
|
-
@deprecations << { type: 'Using --debug instead of --log-level debug', msg: msg }
|
1022
|
-
end
|
1023
916
|
define('--log-level LEVEL',
|
1024
917
|
"Set the log level for the console. Available options are",
|
1025
918
|
"trace, debug, info, warn, error, fatal, any.") do |level|
|