bolt 2.42.0 → 2.44.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.

Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +12 -12
  3. data/bolt-modules/boltlib/lib/puppet/functions/parallelize.rb +6 -8
  4. data/lib/bolt/analytics.rb +3 -2
  5. data/lib/bolt/applicator.rb +11 -1
  6. data/lib/bolt/bolt_option_parser.rb +20 -13
  7. data/lib/bolt/catalog.rb +10 -29
  8. data/lib/bolt/cli.rb +22 -32
  9. data/lib/bolt/config.rb +84 -82
  10. data/lib/bolt/config/options.rb +68 -0
  11. data/lib/bolt/config/transport/options.rb +7 -0
  12. data/lib/bolt/config/transport/orch.rb +1 -0
  13. data/lib/bolt/executor.rb +15 -5
  14. data/lib/bolt/inventory.rb +1 -1
  15. data/lib/bolt/inventory/group.rb +7 -4
  16. data/lib/bolt/logger.rb +114 -10
  17. data/lib/bolt/module_installer.rb +4 -2
  18. data/lib/bolt/module_installer/resolver.rb +59 -14
  19. data/lib/bolt/module_installer/specs/forge_spec.rb +8 -2
  20. data/lib/bolt/module_installer/specs/git_spec.rb +17 -2
  21. data/lib/bolt/outputter/human.rb +8 -4
  22. data/lib/bolt/outputter/rainbow.rb +3 -3
  23. data/lib/bolt/pal.rb +93 -14
  24. data/lib/bolt/pal/yaml_plan.rb +8 -2
  25. data/lib/bolt/pal/yaml_plan/evaluator.rb +2 -2
  26. data/lib/bolt/pal/yaml_plan/transpiler.rb +1 -0
  27. data/lib/bolt/plugin.rb +2 -2
  28. data/lib/bolt/plugin/cache.rb +7 -7
  29. data/lib/bolt/plugin/module.rb +1 -1
  30. data/lib/bolt/plugin/puppet_connect_data.rb +35 -0
  31. data/lib/bolt/plugin/puppetdb.rb +1 -1
  32. data/lib/bolt/project.rb +56 -43
  33. data/lib/bolt/rerun.rb +1 -1
  34. data/lib/bolt/shell/bash.rb +1 -1
  35. data/lib/bolt/shell/bash/tmpdir.rb +4 -1
  36. data/lib/bolt/shell/powershell.rb +2 -2
  37. data/lib/bolt/task.rb +1 -1
  38. data/lib/bolt/transport/docker/connection.rb +2 -2
  39. data/lib/bolt/transport/local.rb +1 -1
  40. data/lib/bolt/transport/orch/connection.rb +1 -1
  41. data/lib/bolt/transport/ssh.rb +1 -2
  42. data/lib/bolt/transport/ssh/connection.rb +1 -1
  43. data/lib/bolt/validator.rb +2 -2
  44. data/lib/bolt/version.rb +1 -1
  45. data/lib/bolt_server/config.rb +1 -1
  46. data/lib/bolt_server/transport_app.rb +2 -1
  47. data/libexec/bolt_catalog +1 -1
  48. metadata +9 -8
@@ -12,46 +12,49 @@ module Bolt
12
12
  CONFIG_NAME = 'bolt-project.yaml'
13
13
 
14
14
  attr_reader :path, :data, :config_file, :inventory_file, :hiera_config,
15
- :puppetfile, :rerunfile, :type, :resource_types, :logs, :project_file,
16
- :deprecations, :downloads, :plans_path, :modulepath, :managed_moduledir,
17
- :backup_dir, :cache_file
15
+ :puppetfile, :rerunfile, :type, :resource_types, :project_file,
16
+ :downloads, :plans_path, :modulepath, :managed_moduledir,
17
+ :backup_dir, :plugin_cache_file, :plan_cache_file
18
18
 
19
- def self.default_project(logs = [])
20
- create_project(File.expand_path(File.join('~', '.puppetlabs', 'bolt')), 'user', logs)
19
+ def self.default_project
20
+ create_project(File.expand_path(File.join('~', '.puppetlabs', 'bolt')), 'user')
21
21
  # If homedir isn't defined use the system config path
22
22
  rescue ArgumentError
23
- create_project(Bolt::Config.system_path, 'system', logs)
23
+ create_project(Bolt::Config.system_path, 'system')
24
24
  end
25
25
 
26
26
  # Search recursively up the directory hierarchy for the Project. Look for a
27
27
  # directory called Boltdir or a file called bolt.yaml (for a control repo
28
28
  # type Project). Otherwise, repeat the check on each directory up the
29
29
  # hierarchy, falling back to the default if we reach the root.
30
- def self.find_boltdir(dir, logs = [], deprecations = [])
30
+ def self.find_boltdir(dir)
31
31
  dir = Pathname.new(dir)
32
32
 
33
33
  if (dir + BOLTDIR_NAME).directory?
34
- create_project(dir + BOLTDIR_NAME, 'embedded', logs)
34
+ create_project(dir + BOLTDIR_NAME, 'embedded')
35
35
  elsif (dir + 'bolt.yaml').file?
36
36
  command = Bolt::Util.powershell? ? 'Update-BoltProject' : 'bolt project migrate'
37
- msg = "Configuration file #{dir + 'bolt.yaml'} is deprecated and will be "\
37
+ Bolt::Logger.deprecate(
38
+ "bolt_yaml",
39
+ "Configuration file #{dir + 'bolt.yaml'} is deprecated and will be "\
38
40
  "removed in Bolt 3.0.\nUpdate your Bolt project to the latest Bolt practices "\
39
- "using #{command}"
40
- deprecations << { type: "Project level bolt.yaml",
41
- msg: msg }
42
- create_project(dir, 'local', logs, deprecations)
41
+ "using #{command}."
42
+ )
43
+ create_project(dir, 'local')
43
44
  elsif (dir + CONFIG_NAME).file?
44
- create_project(dir, 'local', logs)
45
+ create_project(dir, 'local')
45
46
  elsif dir.root?
46
- default_project(logs)
47
+ default_project
47
48
  else
48
- logs << { debug: "Did not detect Boltdir, bolt.yaml, or bolt-project.yaml at '#{dir}'. "\
49
- "This directory won't be loaded as a project." }
50
- find_boltdir(dir.parent, logs, deprecations)
49
+ Bolt::Logger.debug(
50
+ "Did not detect Boltdir, bolt.yaml, or bolt-project.yaml at '#{dir}'. "\
51
+ "This directory won't be loaded as a project."
52
+ )
53
+ find_boltdir(dir.parent)
51
54
  end
52
55
  end
53
56
 
54
- def self.create_project(path, type = 'option', logs = [], deprecations = [])
57
+ def self.create_project(path, type = 'option')
55
58
  fullpath = Pathname.new(path).expand_path
56
59
 
57
60
  if type == 'user'
@@ -59,8 +62,11 @@ module Bolt
59
62
  # This is already expanded if the type is user
60
63
  FileUtils.mkdir_p(path)
61
64
  rescue StandardError
62
- logs << { warn: "Could not create default project at #{path}. Continuing without a writeable project. "\
63
- "Log and rerun files will not be written." }
65
+ Bolt::Logger.warn(
66
+ "non_writeable_project",
67
+ "Could not create default project at #{path}. Continuing without a writeable project. "\
68
+ "Log and rerun files will not be written."
69
+ )
64
70
  end
65
71
  end
66
72
 
@@ -81,19 +87,17 @@ module Bolt
81
87
  default = type =~ /user|system/ ? 'default ' : ''
82
88
  exist = File.exist?(File.expand_path(project_file))
83
89
 
84
- logs << { info: "Loaded #{default}project from '#{fullpath}'" } if exist
90
+ if exist
91
+ Bolt::Logger.info("Loaded #{default}project from '#{fullpath}'")
92
+ end
85
93
 
86
94
  Bolt::Validator.new.tap do |validator|
87
95
  validator.validate(data, schema, project_file)
88
-
89
- validator.warnings.each { |warning| logs << { warn: warning } }
90
-
91
- validator.deprecations.each do |dep|
92
- deprecations << { type: "#{CONFIG_NAME} #{dep[:option]}", msg: dep[:message] }
93
- end
96
+ validator.warnings.each { |warning| Bolt::Logger.warn(warning[:id], warning[:msg]) }
97
+ validator.deprecations.each { |dep| Bolt::Logger.deprecate(dep[:id], dep[:msg]) }
94
98
  end
95
99
 
96
- new(data, path, type, logs, deprecations)
100
+ new(data, path, type)
97
101
  end
98
102
 
99
103
  # Builds the schema for bolt-project.yaml used by the validator.
@@ -106,17 +110,17 @@ module Bolt
106
110
  }
107
111
  end
108
112
 
109
- def initialize(raw_data, path, type = 'option', logs = [], deprecations = [])
113
+ def initialize(raw_data, path, type = 'option')
110
114
  @path = Pathname.new(path).expand_path
111
115
  @project_file = @path + CONFIG_NAME
112
- @logs = logs
113
- @deprecations = deprecations
114
116
 
115
117
  if (@path + 'bolt.yaml').file? && project_file?
116
- msg = "Project-level configuration in bolt.yaml is deprecated if using bolt-project.yaml. "\
118
+ Bolt::Logger.deprecate(
119
+ "bolt_yaml",
120
+ "Project-level configuration in bolt.yaml is deprecated if using bolt-project.yaml. "\
117
121
  "Transport config should be set in inventory.yaml, all other config should be set in "\
118
122
  "bolt-project.yaml."
119
- @deprecations << { type: 'Using bolt.yaml for project configuration', msg: msg }
123
+ )
120
124
  end
121
125
 
122
126
  @inventory_file = @path + 'inventory.yaml'
@@ -129,12 +133,14 @@ module Bolt
129
133
  @plans_path = @path + 'plans'
130
134
  @managed_moduledir = @path + '.modules'
131
135
  @backup_dir = @path + '.bolt-bak'
132
- @cache_file = @path + '.plugin_cache.json'
136
+ @plugin_cache_file = @path + '.plugin_cache.json'
137
+ @plan_cache_file = @path + '.plan_cache.json'
133
138
 
134
- tc = Bolt::Config::INVENTORY_OPTIONS.keys & raw_data.keys
135
- if tc.any?
136
- msg = "Transport configuration isn't supported in bolt-project.yaml. Ignoring keys #{tc}"
137
- @logs << { warn: msg }
139
+ if (tc = Bolt::Config::INVENTORY_OPTIONS.keys & raw_data.keys).any?
140
+ Bolt::Logger.warn(
141
+ "project_transport_config",
142
+ "Transport configuration isn't supported in bolt-project.yaml. Ignoring keys #{tc}."
143
+ )
138
144
  end
139
145
 
140
146
  @data = raw_data.reject { |k, _| Bolt::Config::INVENTORY_OPTIONS.include?(k) }
@@ -151,8 +157,10 @@ module Bolt
151
157
  # and replaced with .project_file in lib/bolt/config.rb
152
158
  @config_file = if (Bolt::Config::BOLT_OPTIONS & @data.keys).any?
153
159
  if (@path + 'bolt.yaml').file?
154
- msg = "bolt-project.yaml contains valid config keys, bolt.yaml will be ignored"
155
- @logs << { warn: msg }
160
+ Bolt::Logger.warn(
161
+ "project_config_conflict",
162
+ "bolt-project.yaml contains valid config keys, bolt.yaml will be ignored"
163
+ )
156
164
  end
157
165
  @project_file
158
166
  else
@@ -206,6 +214,10 @@ module Bolt
206
214
  @data['module-install']
207
215
  end
208
216
 
217
+ def disable_warnings
218
+ @data['disable-warnings'] || []
219
+ end
220
+
209
221
  def modules
210
222
  @modules ||= @data['modules']&.map do |mod|
211
223
  if mod.is_a?(String)
@@ -232,14 +244,15 @@ module Bolt
232
244
  File.directory?(@path + 'tasks') ||
233
245
  File.directory?(@path + 'files'))
234
246
  message = "No project name is specified in bolt-project.yaml. Project-level content will not be available."
235
- @logs << { warn: message }
247
+
248
+ Bolt::Logger.warn("missing_project_name", message)
236
249
  end
237
250
  end
238
251
 
239
252
  def check_deprecated_file
240
253
  if (@path + 'project.yaml').file?
241
254
  msg = "Project configuration file 'project.yaml' is deprecated; use 'bolt-project.yaml' instead."
242
- Bolt::Logger.deprecation_warning('Using project.yaml instead of bolt-project.yaml', msg)
255
+ Bolt::Logger.warn("project_yaml", msg)
243
256
  end
244
257
  end
245
258
  end
@@ -49,7 +49,7 @@ module Bolt
49
49
  end
50
50
  end
51
51
  rescue StandardError => e
52
- Bolt::Logger.warn_once('unwriteable_file', "Failed to save result to #{@path}: #{e.message}")
52
+ Bolt::Logger.warn_once("unwriteable_file", "Failed to save result to #{@path}: #{e.message}")
53
53
  end
54
54
  end
55
55
  end
@@ -299,7 +299,7 @@ module Bolt
299
299
  if target.options['cleanup']
300
300
  dir.delete
301
301
  else
302
- @logger.warn("Skipping cleanup of tmpdir #{dir}")
302
+ Bolt::Logger.warn("skip_cleanup", "Skipping cleanup of tmpdir #{dir}")
303
303
  end
304
304
  end
305
305
  end
@@ -48,7 +48,10 @@ module Bolt
48
48
  def delete
49
49
  result = @shell.execute(['rm', '-rf', @path], sudoable: true, run_as: @owner)
50
50
  if result.exit_code != 0
51
- @logger.warn("Failed to clean up tmpdir '#{@path}': #{result.stderr.string}")
51
+ Bolt::Logger.warn(
52
+ "fail_cleanup",
53
+ "Failed to clean up tmpdir '#{@path}': #{result.stderr.string}"
54
+ )
52
55
  end
53
56
  # For testing
54
57
  result.stderr.string
@@ -27,7 +27,7 @@ module Bolt
27
27
  "bolt-debug.log or run with '--log-level debug' to see the full "\
28
28
  "list of targets with PowerShell 2."
29
29
 
30
- Bolt::Logger.deprecation_warning("PowerShell 2", msg)
30
+ Bolt::Logger.deprecate_once("powershell_2", msg)
31
31
  @logger.debug("Detected PowerShell 2 on #{target}.")
32
32
  end
33
33
  end
@@ -163,7 +163,7 @@ module Bolt
163
163
  if target.options['cleanup']
164
164
  rmdir(@tmpdir)
165
165
  else
166
- @logger.warn("Skipping cleanup of tmpdir '#{@tmpdir}'")
166
+ Bolt::Logger.warn("Skipping cleanup of tmpdir '#{@tmpdir}'", "skip_cleanup")
167
167
  end
168
168
  end
169
169
  end
@@ -149,7 +149,7 @@ module Bolt
149
149
  if unknown_keys.any?
150
150
  msg = "Metadata for task '#{@name}' contains unknown keys: #{unknown_keys.join(', ')}."
151
151
  msg += " This could be a typo in the task metadata or may result in incorrect behavior."
152
- @logger.warn(msg)
152
+ Bolt::Logger.warn("unknown_task_metadata_keys", msg)
153
153
  end
154
154
  end
155
155
  end
@@ -140,10 +140,10 @@ module Bolt
140
140
  if @target.options['cleanup']
141
141
  _, stderr, exitcode = execute('rm', '-rf', dir, {})
142
142
  if exitcode != 0
143
- @logger.warn("Failed to clean up tmpdir '#{dir}': #{stderr}")
143
+ Bolt::Logger.warn("fail_cleanup", "Failed to clean up tmpdir '#{dir}': #{stderr}")
144
144
  end
145
145
  else
146
- @logger.warn("Skipping cleanup of tmpdir '#{dir}'")
146
+ Bolt::Logger.warn("skip_cleanup", "Skipping cleanup of tmpdir '#{dir}'")
147
147
  end
148
148
  end
149
149
  end
@@ -20,7 +20,7 @@ module Bolt
20
20
  msg = "The local transport will default to using Bolt's Ruby interpreter and "\
21
21
  "setting the 'puppet-agent' feature in Bolt 3.0. Enable or disable these "\
22
22
  "defaults by setting 'bundled-ruby' in the local transport config."
23
- Bolt::Logger.warn_once('local default config', msg)
23
+ Bolt::Logger.warn_once("local_default_config", msg)
24
24
  end
25
25
 
26
26
  yield Connection.new(target)
@@ -21,7 +21,7 @@ module Bolt
21
21
 
22
22
  @logger = logger
23
23
  @key = self.class.get_key(opts)
24
- client_opts = opts.slice('token-file', 'cacert', 'job-poll-interval', 'job-poll-timeout')
24
+ client_opts = opts.slice('token-file', 'cacert', 'job-poll-interval', 'job-poll-timeout', 'read-timeout')
25
25
 
26
26
  if opts['service-url']
27
27
  uri = Addressable::URI.parse(opts['service-url'])
@@ -23,8 +23,7 @@ module Bolt
23
23
 
24
24
  def with_connection(target)
25
25
  if target.transport_config['ssh-command'] && !target.transport_config['native-ssh']
26
- Bolt::Logger.warn_once("ssh-command and native-ssh conflict",
27
- "native-ssh must be true to use ssh-command")
26
+ Bolt::Logger.warn_once("native_ssh_disabled", "native-ssh must be true to use ssh-command")
28
27
  end
29
28
 
30
29
  conn = if target.transport_config['native-ssh']
@@ -34,7 +34,7 @@ module Bolt
34
34
  begin
35
35
  Bolt::Util.validate_file('ssh key', target.options['private-key'])
36
36
  rescue Bolt::FileError => e
37
- @logger.warn(e.msg)
37
+ Bolt::Logger.warn("invalid_ssh_key", e.msg)
38
38
  end
39
39
  end
40
40
  end
@@ -147,7 +147,7 @@ module Bolt
147
147
  message += " at '#{path}'" if @path.any?
148
148
  message += " at #{@location}" if @location
149
149
  message += "."
150
- @warnings << message
150
+ @warnings << { id: 'unknown_option', msg: message }
151
151
  end
152
152
  end
153
153
 
@@ -160,7 +160,7 @@ module Bolt
160
160
  message = "Option '#{path}' "
161
161
  message += "at #{@location} " if @location
162
162
  message += "is deprecated. #{definition[:_deprecation]}"
163
- @deprecations << { option: key, message: message }
163
+ @deprecations << { id: "#{key}_option", msg: message }
164
164
  end
165
165
  end
166
166
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bolt
4
- VERSION = '2.42.0'
4
+ VERSION = '2.44.0'
5
5
  end
@@ -9,7 +9,7 @@ module BoltServer
9
9
  def config_keys
10
10
  super + %w[concurrency cache-dir file-server-conn-timeout
11
11
  file-server-uri projects-dir environments-codedir
12
- environmentpath basemodulepath]
12
+ environmentpath basemodulepath builtin-content-dir]
13
13
  end
14
14
 
15
15
  def env_keys
@@ -280,7 +280,8 @@ module BoltServer
280
280
  bolt_config = config_from_project(versioned_project)
281
281
  modulepath_object = Bolt::Config::Modulepath.new(
282
282
  bolt_config.modulepath,
283
- boltlib_path: [PE_BOLTLIB_PATH, Bolt::Config::Modulepath::BOLTLIB_PATH]
283
+ boltlib_path: [PE_BOLTLIB_PATH, Bolt::Config::Modulepath::BOLTLIB_PATH],
284
+ builtin_content_path: @config['builtin-content-dir']
284
285
  )
285
286
  pal = Bolt::PAL.new(modulepath_object, nil, nil, nil, nil, nil, bolt_config.project)
286
287
  context = {
@@ -56,7 +56,7 @@ when "compile"
56
56
  else
57
57
  e.message
58
58
  end
59
- puts({ message: message }.to_json)
59
+ puts({ message: message, backtrace: e.backtrace }.to_json)
60
60
  exit 1
61
61
  rescue StandardError => e
62
62
  puts({ message: e.message }.to_json)
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: 2.42.0
4
+ version: 2.44.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-01-11 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -184,14 +184,14 @@ dependencies:
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '0.4'
187
+ version: '0.5'
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '0.4'
194
+ version: '0.5'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: puppet
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -350,16 +350,16 @@ dependencies:
350
350
  name: puppetlabs_spec_helper
351
351
  requirement: !ruby/object:Gem::Requirement
352
352
  requirements:
353
- - - "~>"
353
+ - - "<="
354
354
  - !ruby/object:Gem::Version
355
- version: '2.7'
355
+ version: 2.15.0
356
356
  type: :development
357
357
  prerelease: false
358
358
  version_requirements: !ruby/object:Gem::Requirement
359
359
  requirements:
360
- - - "~>"
360
+ - - "<="
361
361
  - !ruby/object:Gem::Version
362
- version: '2.7'
362
+ version: 2.15.0
363
363
  - !ruby/object:Gem::Dependency
364
364
  name: rake
365
365
  requirement: !ruby/object:Gem::Requirement
@@ -523,6 +523,7 @@ files:
523
523
  - lib/bolt/plugin/env_var.rb
524
524
  - lib/bolt/plugin/module.rb
525
525
  - lib/bolt/plugin/prompt.rb
526
+ - lib/bolt/plugin/puppet_connect_data.rb
526
527
  - lib/bolt/plugin/puppetdb.rb
527
528
  - lib/bolt/plugin/task.rb
528
529
  - lib/bolt/project.rb