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
data/lib/bolt/config.rb
CHANGED
@@ -22,8 +22,7 @@ module Bolt
|
|
22
22
|
|
23
23
|
attr_reader :config_files, :data, :transports, :project, :modified_concurrency
|
24
24
|
|
25
|
-
|
26
|
-
BOLT_DEFAULTS_NAME = 'bolt-defaults.yaml'
|
25
|
+
DEFAULTS_NAME = 'bolt-defaults.yaml'
|
27
26
|
|
28
27
|
# The default concurrency value that is used when the ulimit is not low (i.e. < 700)
|
29
28
|
DEFAULT_DEFAULT_CONCURRENCY = 100
|
@@ -33,57 +32,9 @@ module Bolt
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def self.from_project(project, overrides = {})
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
c = Bolt::Util.read_optional_yaml_hash(project.config_file, 'config')
|
40
|
-
|
41
|
-
# Validate the config against the schema. This will raise a single error
|
42
|
-
# with all validation errors.
|
43
|
-
Bolt::Validator.new.tap do |validator|
|
44
|
-
validator.validate(c, bolt_schema, project.config_file.to_s)
|
45
|
-
validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
|
46
|
-
validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
|
47
|
-
end
|
48
|
-
|
49
|
-
if File.exist?(project.config_file)
|
50
|
-
Bolt::Logger.debug("Loaded configuration from #{project.config_file}")
|
51
|
-
end
|
52
|
-
c
|
53
|
-
end
|
54
|
-
|
55
|
-
data = load_defaults(project).push(
|
56
|
-
filepath: project.config_file,
|
57
|
-
data: conf
|
58
|
-
)
|
59
|
-
|
60
|
-
new(project, data, overrides)
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.from_file(configfile, overrides = {})
|
64
|
-
project = Bolt::Project.create_project(Pathname.new(configfile).expand_path.dirname)
|
65
|
-
|
66
|
-
conf = if project.project_file == project.config_file
|
67
|
-
project.data
|
68
|
-
else
|
69
|
-
c = Bolt::Util.read_yaml_hash(configfile, 'config')
|
70
|
-
|
71
|
-
# Validate the config against the schema. This will raise a single error
|
72
|
-
# with all validation errors.
|
73
|
-
Bolt::Validator.new.tap do |validator|
|
74
|
-
validator.validate(c, bolt_schema, project.config_file.to_s)
|
75
|
-
validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
|
76
|
-
validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
|
77
|
-
end
|
78
|
-
|
79
|
-
Bolt::Logger.debug("Loaded configuration from #{configfile}")
|
80
|
-
|
81
|
-
c
|
82
|
-
end
|
83
|
-
|
84
|
-
data = load_defaults(project).push(
|
85
|
-
filepath: configfile,
|
86
|
-
data: conf
|
35
|
+
data = load_defaults.push(
|
36
|
+
filepath: project.project_file,
|
37
|
+
data: project.data
|
87
38
|
)
|
88
39
|
|
89
40
|
new(project, data, overrides)
|
@@ -102,7 +53,7 @@ module Bolt
|
|
102
53
|
def self.defaults_schema
|
103
54
|
schema = {
|
104
55
|
type: Hash,
|
105
|
-
properties:
|
56
|
+
properties: DEFAULTS_OPTIONS.map { |opt| [opt, _ref: opt] }.to_h,
|
106
57
|
definitions: OPTIONS.merge(transport_definitions)
|
107
58
|
}
|
108
59
|
|
@@ -111,16 +62,6 @@ module Bolt
|
|
111
62
|
schema
|
112
63
|
end
|
113
64
|
|
114
|
-
# Builds the schema for bolt.yaml used by the validator.
|
115
|
-
#
|
116
|
-
def self.bolt_schema
|
117
|
-
{
|
118
|
-
type: Hash,
|
119
|
-
properties: (BOLT_OPTIONS + INVENTORY_OPTIONS.keys).map { |opt| [opt, _ref: opt] }.to_h,
|
120
|
-
definitions: OPTIONS.merge(transport_definitions)
|
121
|
-
}
|
122
|
-
end
|
123
|
-
|
124
65
|
def self.system_path
|
125
66
|
if Bolt::Util.windows?
|
126
67
|
Pathname.new(File.join(ENV['ALLUSERSPROFILE'], 'PuppetLabs', 'bolt', 'etc'))
|
@@ -136,23 +77,14 @@ module Bolt
|
|
136
77
|
end
|
137
78
|
|
138
79
|
# Loads a 'bolt-defaults.yaml' file, which contains default configuration that applies to all
|
139
|
-
# projects. This file does not allow project-specific configuration such as 'hiera-config'
|
140
|
-
#
|
80
|
+
# projects. This file does not allow project-specific configuration such as 'hiera-config'
|
81
|
+
# and nests all default inventory configuration under an 'inventory-config' key.
|
141
82
|
def self.load_bolt_defaults_yaml(dir)
|
142
|
-
filepath = dir +
|
83
|
+
filepath = dir + DEFAULTS_NAME
|
143
84
|
data = Bolt::Util.read_yaml_hash(filepath, 'config')
|
144
85
|
|
145
86
|
Bolt::Logger.debug("Loaded configuration from #{filepath}")
|
146
87
|
|
147
|
-
# Warn if 'bolt.yaml' detected in same directory.
|
148
|
-
if File.exist?(bolt_yaml = dir + BOLT_CONFIG_NAME)
|
149
|
-
Bolt::Logger.warn(
|
150
|
-
"multiple_config_files",
|
151
|
-
"Detected multiple configuration files: ['#{bolt_yaml}', '#{filepath}']. '#{bolt_yaml}' "\
|
152
|
-
"will be ignored."
|
153
|
-
)
|
154
|
-
end
|
155
|
-
|
156
88
|
# Validate the config against the schema. This will raise a single error
|
157
89
|
# with all validation errors.
|
158
90
|
Bolt::Validator.new.tap do |validator|
|
@@ -162,7 +94,7 @@ module Bolt
|
|
162
94
|
end
|
163
95
|
|
164
96
|
# Remove project-specific config such as hiera-config, etc.
|
165
|
-
project_config = data.slice(*(
|
97
|
+
project_config = data.slice(*(PROJECT_OPTIONS - DEFAULTS_OPTIONS))
|
166
98
|
|
167
99
|
if project_config.any?
|
168
100
|
data.reject! { |key, _| project_config.include?(key) }
|
@@ -210,52 +142,17 @@ module Bolt
|
|
210
142
|
{ filepath: filepath, data: data }
|
211
143
|
end
|
212
144
|
|
213
|
-
|
214
|
-
# here since Bolt::Config will just ignore any invalid keys.
|
215
|
-
def self.load_bolt_yaml(dir)
|
216
|
-
filepath = dir + BOLT_CONFIG_NAME
|
217
|
-
data = Bolt::Util.read_yaml_hash(filepath, 'config')
|
218
|
-
|
219
|
-
Bolt::Logger.debug("Loaded configuration from #{filepath}")
|
220
|
-
|
221
|
-
Bolt::Logger.deprecate(
|
222
|
-
"bolt_yaml",
|
223
|
-
"Configuration file #{filepath} is deprecated and will be removed in Bolt 3.0. "\
|
224
|
-
"See https://pup.pt/update-bolt-config for how to update to the latest Bolt practices."
|
225
|
-
)
|
226
|
-
|
227
|
-
# Validate the config against the schema. This will raise a single error
|
228
|
-
# with all validation errors.
|
229
|
-
Bolt::Validator.new.tap do |validator|
|
230
|
-
validator.validate(data, bolt_schema, filepath)
|
231
|
-
validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
|
232
|
-
validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
|
233
|
-
end
|
234
|
-
|
235
|
-
{ filepath: filepath, data: data }
|
236
|
-
end
|
237
|
-
|
238
|
-
def self.load_defaults(project)
|
145
|
+
def self.load_defaults
|
239
146
|
confs = []
|
240
147
|
|
241
|
-
# Load system-level config.
|
242
|
-
|
243
|
-
# config file, don't load it a second time.
|
244
|
-
if File.exist?(system_path + BOLT_DEFAULTS_NAME)
|
148
|
+
# Load system-level config.
|
149
|
+
if File.exist?(system_path + DEFAULTS_NAME)
|
245
150
|
confs << load_bolt_defaults_yaml(system_path)
|
246
|
-
elsif File.exist?(system_path + BOLT_CONFIG_NAME) &&
|
247
|
-
(system_path + BOLT_CONFIG_NAME) != project.config_file
|
248
|
-
confs << load_bolt_yaml(system_path)
|
249
151
|
end
|
250
152
|
|
251
|
-
# Load user-level config if there is a homedir.
|
252
|
-
|
253
|
-
|
254
|
-
if File.exist?(user_path + BOLT_DEFAULTS_NAME)
|
255
|
-
confs << load_bolt_defaults_yaml(user_path)
|
256
|
-
elsif File.exist?(user_path + BOLT_CONFIG_NAME)
|
257
|
-
confs << load_bolt_yaml(user_path)
|
258
|
-
end
|
153
|
+
# Load user-level config if there is a homedir.
|
154
|
+
if user_path && File.exist?(user_path + DEFAULTS_NAME)
|
155
|
+
confs << load_bolt_defaults_yaml(user_path)
|
259
156
|
end
|
260
157
|
|
261
158
|
confs
|
@@ -263,7 +160,7 @@ module Bolt
|
|
263
160
|
|
264
161
|
def initialize(project, config_data, overrides = {})
|
265
162
|
unless config_data.is_a?(Array)
|
266
|
-
config_data = [{ filepath: project.
|
163
|
+
config_data = [{ filepath: project.project_file, data: config_data }]
|
267
164
|
end
|
268
165
|
|
269
166
|
@logger = Bolt::Logger.logger(self)
|
@@ -273,7 +170,6 @@ module Bolt
|
|
273
170
|
|
274
171
|
default_data = {
|
275
172
|
'apply-settings' => {},
|
276
|
-
'apply_settings' => {},
|
277
173
|
'color' => true,
|
278
174
|
'compile-concurrency' => Etc.nprocessors,
|
279
175
|
'concurrency' => default_concurrency,
|
@@ -282,10 +178,8 @@ module Bolt
|
|
282
178
|
'log' => { 'console' => {} },
|
283
179
|
'module-install' => {},
|
284
180
|
'plugin-hooks' => {},
|
285
|
-
'plugin_hooks' => {},
|
286
181
|
'plugins' => {},
|
287
182
|
'puppetdb' => {},
|
288
|
-
'puppetfile' => {},
|
289
183
|
'save-rerun' => true,
|
290
184
|
'spinner' => true,
|
291
185
|
'transport' => 'ssh'
|
@@ -328,28 +222,25 @@ module Bolt
|
|
328
222
|
def normalize_overrides(options)
|
329
223
|
opts = options.transform_keys(&:to_s)
|
330
224
|
|
331
|
-
# Pull out config options. We need to add 'transport'
|
332
|
-
# OPTIONS hash but
|
333
|
-
overrides = opts.slice(*OPTIONS.keys, 'transport')
|
225
|
+
# Pull out config options. We need to add 'transport' and 'inventoryfile' as they're
|
226
|
+
# not part of the OPTIONS hash but are valid options that can be set with CLI options
|
227
|
+
overrides = opts.slice(*OPTIONS.keys, 'inventoryfile', 'transport')
|
334
228
|
|
335
229
|
# Pull out transport config options
|
336
230
|
TRANSPORT_CONFIG.each do |transport, config|
|
337
231
|
overrides[transport] = opts.slice(*config.options)
|
338
232
|
end
|
339
233
|
|
340
|
-
# Set console log to debug if in debug mode
|
341
|
-
if options[:debug]
|
342
|
-
overrides['log'] = { 'console' => { 'level' => 'debug' } }
|
343
|
-
end
|
344
|
-
|
345
|
-
if options[:puppetfile_path]
|
346
|
-
@puppetfile = options[:puppetfile_path]
|
347
|
-
end
|
348
|
-
|
349
234
|
overrides['trace'] = opts['trace'] if opts.key?('trace')
|
350
235
|
|
351
|
-
# Validate the overrides
|
352
|
-
|
236
|
+
# Validate the overrides that can have arbitrary values
|
237
|
+
schema = {
|
238
|
+
type: Hash,
|
239
|
+
properties: CLI_OPTIONS.map { |opt| [opt, _ref: opt] }.to_h,
|
240
|
+
definitions: OPTIONS.merge(INVENTORY_OPTIONS)
|
241
|
+
}
|
242
|
+
|
243
|
+
Bolt::Validator.new.validate(overrides.slice(*CLI_OPTIONS), schema, 'command line')
|
353
244
|
|
354
245
|
overrides
|
355
246
|
end
|
@@ -367,7 +258,7 @@ module Bolt
|
|
367
258
|
when *TRANSPORT_CONFIG.keys
|
368
259
|
Bolt::Util.deep_merge(val1, val2)
|
369
260
|
# Hash values are shallow merged
|
370
|
-
when '
|
261
|
+
when 'apply-settings', 'log', 'plugin-hooks', 'puppetdb'
|
371
262
|
val1.merge(val2)
|
372
263
|
# Disabled warnings are concatenated
|
373
264
|
when 'disable-warnings'
|
@@ -407,7 +298,7 @@ module Bolt
|
|
407
298
|
end
|
408
299
|
|
409
300
|
# Filter hashes to only include valid options
|
410
|
-
%w[apply-settings
|
301
|
+
%w[apply-settings module-install].each do |opt|
|
411
302
|
@data[opt] = @data[opt].slice(*OPTIONS.dig(opt, :properties).keys)
|
412
303
|
end
|
413
304
|
end
|
@@ -433,13 +324,6 @@ module Bolt
|
|
433
324
|
|
434
325
|
name = normalize_log(key)
|
435
326
|
acc[name] = val.slice('append', 'level').transform_keys(&:to_sym)
|
436
|
-
|
437
|
-
next unless acc[name][:level] == 'notice'
|
438
|
-
|
439
|
-
Bolt::Logger.deprecate(
|
440
|
-
"notice_log_level",
|
441
|
-
"Log level 'notice' is deprecated and will be removed in Bolt 3.0. Use 'info' instead."
|
442
|
-
)
|
443
327
|
end
|
444
328
|
end
|
445
329
|
|
@@ -451,7 +335,7 @@ module Bolt
|
|
451
335
|
)
|
452
336
|
end
|
453
337
|
|
454
|
-
if @
|
338
|
+
if @data['modulepath']&.include?(@project.managed_moduledir.to_s)
|
455
339
|
raise Bolt::ValidationError,
|
456
340
|
"Found invalid path in modulepath: #{@project.managed_moduledir}. This path "\
|
457
341
|
"is automatically appended to the modulepath and cannot be configured."
|
@@ -469,37 +353,6 @@ module Bolt
|
|
469
353
|
if File.exist?(default_inventoryfile)
|
470
354
|
Bolt::Util.validate_file('inventory file', default_inventoryfile)
|
471
355
|
end
|
472
|
-
|
473
|
-
# Warn the user how they should be using the 'puppetfile' or
|
474
|
-
# 'module-install' config options. We don't error here since these
|
475
|
-
# settings can be set at the user or system level.
|
476
|
-
if @project.modules && puppetfile_config.any? && module_install.empty?
|
477
|
-
command = Bolt::Util.powershell? ? 'Update-BoltProject' : 'bolt project migrate'
|
478
|
-
Bolt::Logger.warn(
|
479
|
-
"module_install_config",
|
480
|
-
"Detected configuration for 'puppetfile'. This setting is not "\
|
481
|
-
"used when 'modules' is configured. Use 'module-install' instead. "\
|
482
|
-
"To automatically update your project configuration, run '#{command}'."
|
483
|
-
)
|
484
|
-
elsif @project.modules.nil? && puppetfile_config.empty? && module_install.any?
|
485
|
-
Bolt::Logger.warn(
|
486
|
-
"module_install_config",
|
487
|
-
"Detected configuration for 'module-install'. This setting is not "\
|
488
|
-
"used when 'modules' is not configured. Use 'puppetfile' instead."
|
489
|
-
)
|
490
|
-
elsif @project.modules && puppetfile_config.any? && module_install.any?
|
491
|
-
Bolt::Logger.warn(
|
492
|
-
"module_install_config",
|
493
|
-
"Detected configuration for 'puppetfile' and 'module-install'. Using "\
|
494
|
-
"configuration for 'module-install' because 'modules' is also configured."
|
495
|
-
)
|
496
|
-
elsif @project.modules.nil? && puppetfile_config.any? && module_install.any?
|
497
|
-
Bolt::Logger.warn(
|
498
|
-
"module_install_config",
|
499
|
-
"Detected configuration for 'puppetfile' and 'module-install'. Using "\
|
500
|
-
"configuration for 'puppetfile' because 'modules' is not configured."
|
501
|
-
)
|
502
|
-
end
|
503
356
|
end
|
504
357
|
|
505
358
|
def default_inventoryfile
|
@@ -515,21 +368,15 @@ module Bolt
|
|
515
368
|
end
|
516
369
|
|
517
370
|
def puppetfile
|
518
|
-
@
|
371
|
+
@project.puppetfile
|
519
372
|
end
|
520
373
|
|
521
374
|
def modulepath
|
522
|
-
|
523
|
-
|
524
|
-
if @project.modules
|
525
|
-
path + [@project.managed_moduledir.to_s]
|
526
|
-
else
|
527
|
-
path
|
528
|
-
end
|
375
|
+
(@data['modulepath'] || @project.modulepath) + [@project.managed_moduledir.to_s]
|
529
376
|
end
|
530
377
|
|
531
378
|
def modulepath=(value)
|
532
|
-
@data['modulepath'] = value
|
379
|
+
@data['modulepath'] = Array(value)
|
533
380
|
end
|
534
381
|
|
535
382
|
def plugin_cache
|
@@ -572,6 +419,10 @@ module Bolt
|
|
572
419
|
@data['spinner']
|
573
420
|
end
|
574
421
|
|
422
|
+
def stream
|
423
|
+
@data['stream']
|
424
|
+
end
|
425
|
+
|
575
426
|
def inventoryfile
|
576
427
|
@data['inventoryfile']
|
577
428
|
end
|
@@ -580,27 +431,12 @@ module Bolt
|
|
580
431
|
@data['compile-concurrency']
|
581
432
|
end
|
582
433
|
|
583
|
-
def puppetfile_config
|
584
|
-
@data['puppetfile']
|
585
|
-
end
|
586
|
-
|
587
434
|
def plugins
|
588
435
|
@data['plugins']
|
589
436
|
end
|
590
437
|
|
591
438
|
def plugin_hooks
|
592
|
-
|
593
|
-
Bolt::Logger.warn_once(
|
594
|
-
"plugin_hooks_conflict",
|
595
|
-
"Detected configuration for 'plugin-hooks' and 'plugin_hooks'. Bolt will ignore 'plugin_hooks'."
|
596
|
-
)
|
597
|
-
|
598
|
-
@data['plugin-hooks']
|
599
|
-
elsif @data['plugin-hooks'].any?
|
600
|
-
@data['plugin-hooks']
|
601
|
-
else
|
602
|
-
@data['plugin_hooks']
|
603
|
-
end
|
439
|
+
@data['plugin-hooks']
|
604
440
|
end
|
605
441
|
|
606
442
|
def trusted_external
|
@@ -608,18 +444,7 @@ module Bolt
|
|
608
444
|
end
|
609
445
|
|
610
446
|
def apply_settings
|
611
|
-
|
612
|
-
Bolt::Logger.warn_once(
|
613
|
-
"apply_settings_conflict",
|
614
|
-
"Detected configuration for 'apply-settings' and 'apply_settings'. Bolt will ignore 'apply_settings'."
|
615
|
-
)
|
616
|
-
|
617
|
-
@data['apply-settings']
|
618
|
-
elsif @data['apply-settings'].any?
|
619
|
-
@data['apply-settings']
|
620
|
-
else
|
621
|
-
@data['apply_settings']
|
622
|
-
end
|
447
|
+
@data['apply-settings']
|
623
448
|
end
|
624
449
|
|
625
450
|
def transport
|
data/lib/bolt/config/options.rb
CHANGED
@@ -4,6 +4,7 @@ require 'bolt/config/transport/ssh'
|
|
4
4
|
require 'bolt/config/transport/winrm'
|
5
5
|
require 'bolt/config/transport/orch'
|
6
6
|
require 'bolt/config/transport/local'
|
7
|
+
require 'bolt/config/transport/lxd'
|
7
8
|
require 'bolt/config/transport/docker'
|
8
9
|
require 'bolt/config/transport/remote'
|
9
10
|
|
@@ -17,6 +18,7 @@ module Bolt
|
|
17
18
|
'winrm' => Bolt::Config::Transport::WinRM,
|
18
19
|
'pcp' => Bolt::Config::Transport::Orch,
|
19
20
|
'local' => Bolt::Config::Transport::Local,
|
21
|
+
'lxd' => Bolt::Config::Transport::LXD,
|
20
22
|
'docker' => Bolt::Config::Transport::Docker,
|
21
23
|
'remote' => Bolt::Config::Transport::Remote
|
22
24
|
}.freeze
|
@@ -53,42 +55,6 @@ module Bolt
|
|
53
55
|
# Definitions used to validate config options.
|
54
56
|
# https://github.com/puppetlabs/bolt/blob/main/schemas/README.md
|
55
57
|
OPTIONS = {
|
56
|
-
"apply_settings" => {
|
57
|
-
description: "A map of Puppet settings to use when applying Puppet code using the `apply` "\
|
58
|
-
"plan function or the `bolt apply` command.",
|
59
|
-
type: Hash,
|
60
|
-
properties: {
|
61
|
-
"evaltrace" => {
|
62
|
-
description: "Whether each resource should log when it is being evaluated.",
|
63
|
-
type: [TrueClass, FalseClass],
|
64
|
-
_example: true,
|
65
|
-
_default: false
|
66
|
-
},
|
67
|
-
"log_level" => {
|
68
|
-
description: "The log level for logs in apply reports from Puppet. These can be seen "\
|
69
|
-
"in ApplyResults.",
|
70
|
-
type: String,
|
71
|
-
enum: %w[debug info notice warning err alert emerg crit],
|
72
|
-
_example: "debug",
|
73
|
-
_default: "notice"
|
74
|
-
},
|
75
|
-
"show_diff" => {
|
76
|
-
description: "Whether to log and report a contextual diff.",
|
77
|
-
type: [TrueClass, FalseClass],
|
78
|
-
_example: true,
|
79
|
-
_default: false
|
80
|
-
},
|
81
|
-
"trace" => {
|
82
|
-
description: "Whether to print stack traces on some errors. Will print internal Ruby "\
|
83
|
-
"stack trace interleaved with Puppet function frames.",
|
84
|
-
type: [TrueClass, FalseClass],
|
85
|
-
_example: true,
|
86
|
-
_default: false
|
87
|
-
}
|
88
|
-
},
|
89
|
-
_plugin: false,
|
90
|
-
_deprecation: "This option will be removed in Bolt 3.0. Use `apply-settings` instead."
|
91
|
-
},
|
92
58
|
"apply-settings" => {
|
93
59
|
description: "A map of Puppet settings to use when applying Puppet code using the `apply` "\
|
94
60
|
"plan function or the `bolt apply` command.",
|
@@ -182,18 +148,6 @@ module Bolt
|
|
182
148
|
_plugin: false,
|
183
149
|
_example: {}
|
184
150
|
},
|
185
|
-
"inventoryfile" => {
|
186
|
-
description: "The path to a structured data inventory file used to refer to groups of targets on the "\
|
187
|
-
"command line and from plans. Read more about using inventory files in [Inventory "\
|
188
|
-
"files](inventory_file_v2.md).",
|
189
|
-
type: String,
|
190
|
-
_plugin: false,
|
191
|
-
_deprecation: "This option will be removed in Bolt 3.0. Use the `--inventoryfile` command-line option "\
|
192
|
-
"to use a non-default inventory file or move the file contents to `inventory.yaml` in the "\
|
193
|
-
"project directory.",
|
194
|
-
_example: "~/.puppetlabs/bolt/inventory.yaml",
|
195
|
-
_default: "project/inventory.yaml"
|
196
|
-
},
|
197
151
|
"plugin-cache" => {
|
198
152
|
description: "This feature is experimental. Enable plugin caching and set the time-to-live.",
|
199
153
|
type: Hash,
|
@@ -225,7 +179,7 @@ module Bolt
|
|
225
179
|
"level" => {
|
226
180
|
description: "The type of information to log.",
|
227
181
|
type: String,
|
228
|
-
enum: %w[trace debug error info
|
182
|
+
enum: %w[trace debug error info warn fatal any],
|
229
183
|
_default: "warn"
|
230
184
|
}
|
231
185
|
}
|
@@ -244,7 +198,7 @@ module Bolt
|
|
244
198
|
"level" => {
|
245
199
|
description: "The type of information to log.",
|
246
200
|
type: String,
|
247
|
-
enum: %w[trace debug error info
|
201
|
+
enum: %w[trace debug error info warn fatal any],
|
248
202
|
_default: "warn"
|
249
203
|
}
|
250
204
|
}
|
@@ -262,7 +216,7 @@ module Bolt
|
|
262
216
|
},
|
263
217
|
_plugin: false,
|
264
218
|
_example: ["~/.puppetlabs/bolt/modules", "~/.puppetlabs/bolt/site-modules"],
|
265
|
-
_default: ["project/modules"
|
219
|
+
_default: ["project/modules"]
|
266
220
|
},
|
267
221
|
"module-install" => {
|
268
222
|
description: "Options that configure where Bolt downloads modules from. This option is only used when "\
|
@@ -349,6 +303,7 @@ module Bolt
|
|
349
303
|
]
|
350
304
|
},
|
351
305
|
_plugin: false,
|
306
|
+
_default: [],
|
352
307
|
_example: [
|
353
308
|
"puppetlabs-facts",
|
354
309
|
{ "name" => "puppetlabs-mysql" },
|
@@ -377,16 +332,6 @@ module Bolt
|
|
377
332
|
_plugin: false,
|
378
333
|
_example: ["myproject", "myproject::foo", "myproject::bar", "myproject::deploy::*"]
|
379
334
|
},
|
380
|
-
"plugin_hooks" => {
|
381
|
-
description: "A map of [plugin hooks](writing_plugins.md#hooks) and which plugins a hook should use. "\
|
382
|
-
"The only configurable plugin hook is `puppet_library`, which can use two possible plugins: "\
|
383
|
-
"[`puppet_agent`](https://github.com/puppetlabs/puppetlabs-puppet_agent#puppet_agentinstall) "\
|
384
|
-
"and [`task`](using_plugins.md#task).",
|
385
|
-
type: Hash,
|
386
|
-
_plugin: true,
|
387
|
-
_example: { "puppet_library" => { "plugin" => "puppet_agent", "version" => "6.15.0", "_run_as" => "root" } },
|
388
|
-
_deprecation: "This option will be removed in Bolt 3.0. Use `plugin-hooks` instead."
|
389
|
-
},
|
390
335
|
"plugin-hooks" => {
|
391
336
|
description: "A map of [plugin hooks](writing_plugins.md#hooks) and which plugins a hook should use. "\
|
392
337
|
"The only configurable plugin hook is `puppet_library`, which can use two possible plugins: "\
|
@@ -464,42 +409,6 @@ module Bolt
|
|
464
409
|
},
|
465
410
|
_plugin: true
|
466
411
|
},
|
467
|
-
"puppetfile" => {
|
468
|
-
description: "A map containing options for the `bolt puppetfile install` command and "\
|
469
|
-
"`Install-BoltPuppetfile` cmdlet.",
|
470
|
-
type: Hash,
|
471
|
-
properties: {
|
472
|
-
"forge" => {
|
473
|
-
description: "A subsection that can have its own `proxy` setting to set an HTTP proxy for Forge "\
|
474
|
-
"operations only, and a `baseurl` setting to specify a different Forge host.",
|
475
|
-
type: Hash,
|
476
|
-
properties: {
|
477
|
-
"baseurl" => {
|
478
|
-
description: "The URL to the Forge host.",
|
479
|
-
type: String,
|
480
|
-
format: "uri",
|
481
|
-
_example: "https://forge.example.com"
|
482
|
-
},
|
483
|
-
"proxy" => {
|
484
|
-
description: "The HTTP proxy to use for Forge operations.",
|
485
|
-
type: String,
|
486
|
-
format: "uri",
|
487
|
-
_example: "https://my-forge-proxy.com:8080"
|
488
|
-
}
|
489
|
-
},
|
490
|
-
_example: { "baseurl" => "https://forge.example.com", "proxy" => "https://my-forge-proxy.com:8080" }
|
491
|
-
},
|
492
|
-
"proxy" => {
|
493
|
-
description: "The HTTP proxy to use for Git and Forge operations.",
|
494
|
-
type: String,
|
495
|
-
format: "uri",
|
496
|
-
_example: "https://my-proxy.com:8080"
|
497
|
-
}
|
498
|
-
},
|
499
|
-
_deprecation: "This option will be removed in Bolt 3.0. Update your project to use the module "\
|
500
|
-
"management feature. For more information, see https://pup.pt/bolt-module-migrate.",
|
501
|
-
_plugin: false
|
502
|
-
},
|
503
412
|
"save-rerun" => {
|
504
413
|
description: "Whether to update `.rerun.json` in the Bolt project directory. If "\
|
505
414
|
"your target names include passwords, set this value to `false` to avoid "\
|
@@ -516,7 +425,14 @@ module Bolt
|
|
516
425
|
_example: false,
|
517
426
|
_default: true
|
518
427
|
},
|
519
|
-
|
428
|
+
"stream" => {
|
429
|
+
description: "Whether to stream output from scripts and commands to the console. "\
|
430
|
+
"**This option is experimental**.",
|
431
|
+
type: [TrueClass, FalseClass],
|
432
|
+
_plugin: false,
|
433
|
+
_default: false,
|
434
|
+
_example: true
|
435
|
+
},
|
520
436
|
"tasks" => {
|
521
437
|
description: "A list of task names and glob patterns to filter the project's tasks by. This option is used "\
|
522
438
|
"to limit the visibility of tasks for users of the project. For example, project authors "\
|
@@ -533,8 +449,8 @@ module Bolt
|
|
533
449
|
},
|
534
450
|
"trusted-external-command" => {
|
535
451
|
description: "The path to an executable on the Bolt controller that can produce external trusted facts. "\
|
536
|
-
"**External trusted facts are experimental in both Puppet and Bolt and this API
|
537
|
-
"be removed.**",
|
452
|
+
"**External trusted facts are experimental in both Puppet and Bolt and this API might "\
|
453
|
+
"change or be removed.**",
|
538
454
|
type: String,
|
539
455
|
_plugin: false,
|
540
456
|
_example: "/etc/puppetlabs/facts/trusted_external.sh"
|
@@ -543,8 +459,8 @@ module Bolt
|
|
543
459
|
|
544
460
|
# Options that configure the inventory, specifically the default transport
|
545
461
|
# used by targets and the transports themselves. These options are used in
|
546
|
-
# bolt.yaml
|
547
|
-
# '
|
462
|
+
# bolt-defaults.yaml under 'inventory-config' and in inventory.yaml under
|
463
|
+
# 'config'.
|
548
464
|
INVENTORY_OPTIONS = {
|
549
465
|
"transport" => {
|
550
466
|
description: "The default transport to use when the transport for a target is not "\
|
@@ -568,6 +484,13 @@ module Bolt
|
|
568
484
|
_plugin: true,
|
569
485
|
_example: { "cleanup" => false, "tmpdir" => "/tmp/bolt" }
|
570
486
|
},
|
487
|
+
"lxd" => {
|
488
|
+
description: "A map of configuration options for the LXD transport. The LXD transport is "\
|
489
|
+
"experimental and might include breaking changes between minor versions.",
|
490
|
+
type: Hash,
|
491
|
+
_plugin: true,
|
492
|
+
_example: { cleanup: false }
|
493
|
+
},
|
571
494
|
"pcp" => {
|
572
495
|
description: "A map of configuration options for the pcp transport.",
|
573
496
|
type: Hash,
|
@@ -595,30 +518,20 @@ module Bolt
|
|
595
518
|
}
|
596
519
|
}.freeze
|
597
520
|
|
598
|
-
# Options that are available
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
color
|
521
|
+
# Options that are available on the command line
|
522
|
+
# This only includes options where users can provide arbitrary
|
523
|
+
# values from the command-line, allowing the validator to check them
|
524
|
+
CLI_OPTIONS = %w[
|
603
525
|
compile-concurrency
|
604
526
|
concurrency
|
605
527
|
format
|
606
|
-
hiera-config
|
607
|
-
inventoryfile
|
608
528
|
log
|
609
529
|
modulepath
|
610
|
-
|
611
|
-
plugin_hooks
|
612
|
-
plugins
|
613
|
-
puppetdb
|
614
|
-
puppetfile
|
615
|
-
save-rerun
|
616
|
-
spinner
|
617
|
-
trusted-external-command
|
530
|
+
transport
|
618
531
|
].freeze
|
619
532
|
|
620
533
|
# Options that are available in a bolt-defaults.yaml file
|
621
|
-
|
534
|
+
DEFAULTS_OPTIONS = %w[
|
622
535
|
color
|
623
536
|
compile-concurrency
|
624
537
|
concurrency
|
@@ -629,25 +542,22 @@ module Bolt
|
|
629
542
|
module-install
|
630
543
|
plugin-cache
|
631
544
|
plugin-hooks
|
632
|
-
plugin_hooks
|
633
545
|
plugins
|
634
546
|
puppetdb
|
635
|
-
puppetfile
|
636
547
|
save-rerun
|
637
548
|
spinner
|
549
|
+
stream
|
638
550
|
].freeze
|
639
551
|
|
640
552
|
# Options that are available in a bolt-project.yaml file
|
641
|
-
|
553
|
+
PROJECT_OPTIONS = %w[
|
642
554
|
apply-settings
|
643
|
-
apply_settings
|
644
555
|
color
|
645
556
|
compile-concurrency
|
646
557
|
concurrency
|
647
558
|
disable-warnings
|
648
559
|
format
|
649
560
|
hiera-config
|
650
|
-
inventoryfile
|
651
561
|
log
|
652
562
|
modulepath
|
653
563
|
module-install
|
@@ -656,12 +566,11 @@ module Bolt
|
|
656
566
|
plans
|
657
567
|
plugin-cache
|
658
568
|
plugin-hooks
|
659
|
-
plugin_hooks
|
660
569
|
plugins
|
661
570
|
puppetdb
|
662
|
-
puppetfile
|
663
571
|
save-rerun
|
664
572
|
spinner
|
573
|
+
stream
|
665
574
|
tasks
|
666
575
|
trusted-external-command
|
667
576
|
].freeze
|