bolt 2.40.1 → 3.0.1
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 +17 -17
- 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/wait_until_available.rb +7 -3
- data/lib/bolt/analytics.rb +3 -2
- data/lib/bolt/applicator.rb +11 -1
- data/lib/bolt/bolt_option_parser.rb +3 -113
- data/lib/bolt/catalog.rb +10 -29
- data/lib/bolt/cli.rb +58 -157
- data/lib/bolt/config.rb +62 -239
- data/lib/bolt/config/options.rb +58 -97
- data/lib/bolt/config/transport/local.rb +1 -0
- data/lib/bolt/config/transport/options.rb +8 -1
- data/lib/bolt/config/transport/orch.rb +1 -0
- data/lib/bolt/executor.rb +15 -5
- data/lib/bolt/inventory.rb +3 -2
- data/lib/bolt/inventory/group.rb +35 -4
- data/lib/bolt/inventory/inventory.rb +1 -1
- data/lib/bolt/logger.rb +115 -11
- data/lib/bolt/module.rb +10 -2
- data/lib/bolt/module_installer.rb +4 -2
- data/lib/bolt/module_installer/resolver.rb +65 -12
- data/lib/bolt/module_installer/specs/forge_spec.rb +8 -2
- data/lib/bolt/module_installer/specs/git_spec.rb +17 -2
- data/lib/bolt/outputter/human.rb +9 -5
- data/lib/bolt/outputter/json.rb +16 -16
- data/lib/bolt/outputter/rainbow.rb +3 -3
- data/lib/bolt/pal.rb +93 -14
- data/lib/bolt/pal/yaml_plan.rb +8 -2
- data/lib/bolt/pal/yaml_plan/evaluator.rb +7 -19
- data/lib/bolt/pal/yaml_plan/step.rb +3 -24
- data/lib/bolt/pal/yaml_plan/step/upload.rb +2 -2
- data/lib/bolt/pal/yaml_plan/transpiler.rb +6 -1
- data/lib/bolt/plugin.rb +3 -3
- 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 +4 -3
- data/lib/bolt/project_manager/module_migrator.rb +6 -5
- data/lib/bolt/rerun.rb +1 -1
- data/lib/bolt/shell/bash.rb +1 -1
- data/lib/bolt/shell/bash/tmpdir.rb +4 -1
- data/lib/bolt/shell/powershell.rb +3 -4
- data/lib/bolt/shell/powershell/snippets.rb +9 -149
- data/lib/bolt/task.rb +1 -1
- data/lib/bolt/transport/docker/connection.rb +2 -2
- data/lib/bolt/transport/local.rb +1 -9
- data/lib/bolt/transport/orch/connection.rb +1 -1
- data/lib/bolt/transport/ssh.rb +1 -2
- data/lib/bolt/transport/ssh/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/schemas/partials/task.json +1 -1
- data/lib/bolt_server/transport_app.rb +3 -2
- 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 +31 -0
- data/modules/puppetdb_fact/plans/init.pp +10 -0
- metadata +27 -18
- 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: 16ea129b96b72ea751f0b59599b8783c7c2ad45ebc46004058384693d71795f1
|
4
|
+
data.tar.gz: 9f227b4c8a2fbe06410090adb6590ddce9e8f4ae29a2fa10f0e2e464fa166c0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c6c1b341c1b8d83ec37184a2a9875e0665e4b5a1ed2a6b0c58266b38a541cafffb89df39da659a6ee6157a4140db852d43fa104b3ed7d99400011ec624139a7
|
7
|
+
data.tar.gz: 7f9a485096374549f2d5f29ff00954c810016c751f54d551c9367212ccf889eced3b71a13e262ebd6916ad2568139298b87081412ef96d091aeddeffbb924684
|
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', '1.
|
9
|
-
mod 'puppetlabs-puppet_agent', '4.
|
10
|
-
mod 'puppetlabs-facts', '1.
|
8
|
+
mod 'puppetlabs-service', '1.4.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
13
|
mod 'puppetlabs-augeas_core', '1.1.1'
|
14
14
|
mod 'puppetlabs-host_core', '1.0.3'
|
15
|
-
mod 'puppetlabs-scheduled_task', '2.
|
15
|
+
mod 'puppetlabs-scheduled_task', '2.3.1'
|
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,23 +22,23 @@ 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', '1.
|
26
|
-
mod 'puppetlabs-puppet_conf', '0.
|
27
|
-
mod 'puppetlabs-python_task_helper', '0.
|
28
|
-
mod 'puppetlabs-reboot', '3.
|
29
|
-
mod 'puppetlabs-ruby_task_helper', '0.
|
30
|
-
mod 'puppetlabs-ruby_plugin_helper', '0.
|
31
|
-
mod 'puppetlabs-stdlib', '6.
|
25
|
+
mod 'puppetlabs-package', '1.4.0'
|
26
|
+
mod 'puppetlabs-puppet_conf', '0.8.0'
|
27
|
+
mod 'puppetlabs-python_task_helper', '0.5.0'
|
28
|
+
mod 'puppetlabs-reboot', '3.2.0'
|
29
|
+
mod 'puppetlabs-ruby_task_helper', '0.6.0'
|
30
|
+
mod 'puppetlabs-ruby_plugin_helper', '0.2.0'
|
31
|
+
mod 'puppetlabs-stdlib', '6.6.0'
|
32
32
|
|
33
33
|
# Plugin modules
|
34
|
-
mod 'puppetlabs-aws_inventory', '0.
|
35
|
-
mod 'puppetlabs-azure_inventory', '0.
|
36
|
-
mod 'puppetlabs-gcloud_inventory', '0.
|
34
|
+
mod 'puppetlabs-aws_inventory', '0.6.0'
|
35
|
+
mod 'puppetlabs-azure_inventory', '0.5.0'
|
36
|
+
mod 'puppetlabs-gcloud_inventory', '0.2.0'
|
37
37
|
mod 'puppetlabs-http_request', '0.2.1'
|
38
38
|
mod 'puppetlabs-pkcs7', '0.1.1'
|
39
|
-
mod 'puppetlabs-secure_env_vars', '0.
|
40
|
-
mod 'puppetlabs-terraform', '0.
|
41
|
-
mod 'puppetlabs-vault', '0.
|
39
|
+
mod 'puppetlabs-secure_env_vars', '0.2.0'
|
40
|
+
mod 'puppetlabs-terraform', '0.6.1'
|
41
|
+
mod 'puppetlabs-vault', '0.4.0'
|
42
42
|
mod 'puppetlabs-yaml', '0.2.0'
|
43
43
|
|
44
44
|
# If we don't list these modules explicitly, r10k will purge them
|
@@ -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
|
@@ -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
|
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
|
@@ -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
16
|
display: %w[format color verbose trace],
|
17
|
-
global: %w[help version
|
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
|
@@ -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',
|
@@ -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
|
@@ -1013,13 +910,6 @@ module Bolt
|
|
1013
910
|
puts Bolt::VERSION
|
1014
911
|
raise Bolt::CLIExit
|
1015
912
|
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
913
|
define('--log-level LEVEL',
|
1024
914
|
"Set the log level for the console. Available options are",
|
1025
915
|
"trace, debug, info, warn, error, fatal, any.") do |level|
|
data/lib/bolt/catalog.rb
CHANGED
@@ -76,31 +76,27 @@ module Bolt
|
|
76
76
|
# is the only way to log a message that will make it back to Bolt
|
77
77
|
# to be printed.
|
78
78
|
target = request['target']
|
79
|
-
plan_vars = shadow_vars('plan', request['plan_vars'], target['facts'])
|
80
|
-
target_vars = shadow_vars('target', target['variables'], target['facts'])
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
# these variables are moved before the variable they reference, Puppet will
|
87
|
-
# be unable to deserialize the data and raise an error.
|
88
|
-
topscope_vars = target_vars.reject { |k, _v| plan_vars.key?(k) }.merge(plan_vars)
|
80
|
+
variables = {
|
81
|
+
variables: request['plan_vars'],
|
82
|
+
target_variables: target['variables']
|
83
|
+
}
|
89
84
|
|
90
|
-
env_conf = {
|
91
|
-
|
92
|
-
|
85
|
+
env_conf = {
|
86
|
+
modulepath: request['modulepath'],
|
87
|
+
facts: target['facts']
|
88
|
+
}
|
93
89
|
|
94
90
|
puppet_settings = {
|
95
91
|
node_name_value: target['name'],
|
96
|
-
hiera_config:
|
92
|
+
hiera_config: request['hiera_config']
|
97
93
|
}
|
98
94
|
|
99
95
|
with_puppet_settings(puppet_settings) do
|
100
96
|
Puppet::Pal.in_tmp_environment('bolt_catalog', **env_conf) do |pal|
|
101
97
|
Puppet.override(puppet_overrides) do
|
102
98
|
Puppet.lookup(:pal_current_node).trusted_data = target['trusted']
|
103
|
-
pal.with_catalog_compiler do |compiler|
|
99
|
+
pal.with_catalog_compiler(**variables) do |compiler|
|
104
100
|
options = request['puppet_config'] || {}
|
105
101
|
# Configure language strictness in the CatalogCompiler. We want Bolt to be able
|
106
102
|
# to compile most Puppet 4+ manifests, so we default to allowing deprecated functions.
|
@@ -119,21 +115,6 @@ module Bolt
|
|
119
115
|
end
|
120
116
|
end
|
121
117
|
|
122
|
-
# Warn and remove variables that will be shadowed by facts of the same
|
123
|
-
# name, which are set in scope earlier.
|
124
|
-
def shadow_vars(type, vars, facts)
|
125
|
-
collisions, valid = vars.partition do |k, _|
|
126
|
-
facts.include?(k)
|
127
|
-
end
|
128
|
-
if collisions.any?
|
129
|
-
names = collisions.map { |k, _| "$#{k}" }.join(', ')
|
130
|
-
plural = collisions.length == 1 ? '' : 's'
|
131
|
-
Puppet.warning("#{type.capitalize} variable#{plural} #{names} will be overridden by fact#{plural} " \
|
132
|
-
"of the same name in the apply block")
|
133
|
-
end
|
134
|
-
valid.to_h
|
135
|
-
end
|
136
|
-
|
137
118
|
def build_program(code)
|
138
119
|
ast = Puppet::Pops::Serialization::FromDataConverter.convert(code)
|
139
120
|
|