bolt 2.37.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +17 -17
  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 +58 -40
  9. data/lib/bolt/config.rb +134 -119
  10. data/lib/bolt/config/options.rb +142 -77
  11. data/lib/bolt/config/transport/base.rb +2 -2
  12. data/lib/bolt/config/transport/local.rb +1 -0
  13. data/lib/bolt/config/transport/options.rb +18 -68
  14. data/lib/bolt/config/transport/orch.rb +1 -0
  15. data/lib/bolt/config/transport/ssh.rb +0 -5
  16. data/lib/bolt/executor.rb +15 -5
  17. data/lib/bolt/inventory.rb +26 -0
  18. data/lib/bolt/inventory/group.rb +35 -12
  19. data/lib/bolt/inventory/inventory.rb +1 -1
  20. data/lib/bolt/inventory/options.rb +130 -0
  21. data/lib/bolt/inventory/target.rb +10 -11
  22. data/lib/bolt/logger.rb +114 -10
  23. data/lib/bolt/module.rb +10 -2
  24. data/lib/bolt/module_installer.rb +25 -15
  25. data/lib/bolt/module_installer/resolver.rb +65 -12
  26. data/lib/bolt/module_installer/specs/forge_spec.rb +8 -2
  27. data/lib/bolt/module_installer/specs/git_spec.rb +17 -2
  28. data/lib/bolt/outputter.rb +19 -5
  29. data/lib/bolt/outputter/human.rb +24 -1
  30. data/lib/bolt/outputter/json.rb +1 -1
  31. data/lib/bolt/outputter/logger.rb +1 -1
  32. data/lib/bolt/outputter/rainbow.rb +12 -1
  33. data/lib/bolt/pal.rb +93 -14
  34. data/lib/bolt/pal/yaml_plan.rb +8 -2
  35. data/lib/bolt/pal/yaml_plan/evaluator.rb +2 -2
  36. data/lib/bolt/pal/yaml_plan/transpiler.rb +6 -1
  37. data/lib/bolt/plugin.rb +3 -3
  38. data/lib/bolt/plugin/cache.rb +8 -8
  39. data/lib/bolt/plugin/module.rb +1 -1
  40. data/lib/bolt/plugin/puppet_connect_data.rb +35 -0
  41. data/lib/bolt/plugin/puppetdb.rb +2 -2
  42. data/lib/bolt/project.rb +76 -50
  43. data/lib/bolt/project_manager.rb +2 -0
  44. data/lib/bolt/project_manager/config_migrator.rb +9 -1
  45. data/lib/bolt/project_manager/module_migrator.rb +2 -0
  46. data/lib/bolt/puppetdb/client.rb +8 -0
  47. data/lib/bolt/rerun.rb +1 -1
  48. data/lib/bolt/shell/bash.rb +1 -1
  49. data/lib/bolt/shell/bash/tmpdir.rb +4 -1
  50. data/lib/bolt/shell/powershell.rb +7 -5
  51. data/lib/bolt/target.rb +4 -0
  52. data/lib/bolt/task.rb +1 -1
  53. data/lib/bolt/transport/docker/connection.rb +2 -2
  54. data/lib/bolt/transport/local.rb +13 -0
  55. data/lib/bolt/transport/orch/connection.rb +1 -1
  56. data/lib/bolt/transport/ssh.rb +1 -2
  57. data/lib/bolt/transport/ssh/connection.rb +1 -1
  58. data/lib/bolt/validator.rb +227 -0
  59. data/lib/bolt/version.rb +1 -1
  60. data/lib/bolt_server/config.rb +1 -1
  61. data/lib/bolt_server/schemas/partials/task.json +1 -1
  62. data/lib/bolt_server/transport_app.rb +28 -27
  63. data/libexec/bolt_catalog +1 -1
  64. metadata +27 -11
  65. data/lib/bolt/config/validator.rb +0 -231
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cbd90e42181c76bad4eee913ee67369202296852cfa5153a1f5490def4e77d3
4
- data.tar.gz: 87ac43d10edeebefaa31f581f49cbcf9f729e25f5d7efec583e09dcf04f97be6
3
+ metadata.gz: aa7f2db70ebfda5de9128554d289d3506ad0c922dac4042e80e29ad691b04447
4
+ data.tar.gz: b0eedc91174b14a594352d3033a27c13f4f29dbd038679345568e39bea486bc4
5
5
  SHA512:
6
- metadata.gz: 392f0d453c49a536852692e873e5c5f55807294fa0bd914593722c26d39459e494b83453a3b995319b04b8f2e6f3a1f04f7661400841192bdffc56df47e4170e
7
- data.tar.gz: 750cd8e9c29008e8bb4dfc7350d52a268c01d91fa088e9007ff241648e31a90e76d9cabfef9f1db5675d33f6b82b2898a54f758bc21c17c18d888919d0441807
6
+ metadata.gz: 1d5620a57dbf4ba82778704296116f53b162a469557162f766c208a5ca5d01e52fbdb219c8e9e965823dca7224dfd1dec507cb432d0d64fa29604fc117a1930f
7
+ data.tar.gz: 0fdf98e91e30c49960caf5b67bca32d6698c3df18ce1d75db98831cfc0694ac1ba444c08691e809ba3ecca76d702b16e46154ed5fc65a59db432f27355bf57a0
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.3.0'
9
- mod 'puppetlabs-puppet_agent', '4.2.0'
10
- mod 'puppetlabs-facts', '1.2.0'
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.2.1'
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.3.0'
26
- mod 'puppetlabs-puppet_conf', '0.6.0'
27
- mod 'puppetlabs-python_task_helper', '0.4.3'
28
- mod 'puppetlabs-reboot', '3.0.0'
29
- mod 'puppetlabs-ruby_task_helper', '0.5.1'
30
- mod 'puppetlabs-ruby_plugin_helper', '0.1.0'
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
31
  mod 'puppetlabs-stdlib', '6.5.0'
32
32
 
33
33
  # Plugin modules
34
- mod 'puppetlabs-aws_inventory', '0.5.2'
35
- mod 'puppetlabs-azure_inventory', '0.4.1'
36
- mod 'puppetlabs-gcloud_inventory', '0.1.3'
37
- mod 'puppetlabs-http_request', '0.2.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
+ mod 'puppetlabs-http_request', '0.2.1'
38
38
  mod 'puppetlabs-pkcs7', '0.1.1'
39
- mod 'puppetlabs-secure_env_vars', '0.1.0'
40
- mod 'puppetlabs-terraform', '0.5.0'
41
- mod 'puppetlabs-vault', '0.3.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
@@ -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 multiple targets. Once the task finishes on one
16
- # target, that target can move to the next step without waiting for the task
17
- # to finish on the second target.
18
- # $targets = get_targets(["host1", "host2"])
19
- # $result = parallelize ($targets) |$t| {
20
- # run_task('a', $t)
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
@@ -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
- Bolt::Logger.warn_once('analytics_opt_out', <<~ANALYTICS)
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
- ANALYTICS
89
+ ANALYTICS
90
+ Bolt::Logger.warn_once('analytics_opt_out', msg)
90
91
  end
91
92
 
92
93
  {}
@@ -125,7 +125,16 @@ module Bolt
125
125
  @logger.send(bolt_level, "#{target.name}: #{message}")
126
126
  end
127
127
  end
128
- raise ApplyError.new(target.name, result['message']) unless stat.success?
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
@@ -760,13 +760,10 @@ module Bolt
760
760
  bolt task show canary
761
761
  HELP
762
762
 
763
- attr_reader :deprecations
764
-
765
763
  def initialize(options)
766
764
  super()
767
765
 
768
766
  @options = options
769
- @deprecations = []
770
767
 
771
768
  separator "\nINVENTORY OPTIONS"
772
769
  define('-t', '--targets TARGETS',
@@ -796,9 +793,11 @@ module Bolt
796
793
  end
797
794
  define('--description DESCRIPTION',
798
795
  'Deprecated. Description to use for the job') do |description|
799
- msg = "Command line option '--description' is deprecated, and will be "\
796
+ Bolt::Logger.deprecate(
797
+ "description_cli_option",
798
+ "Command line option '--description' is deprecated, and will be "\
800
799
  "removed in Bolt 3.0."
801
- @deprecations << { type: 'Using --description', msg: msg }
800
+ )
802
801
  @options[:description] = description
803
802
  end
804
803
  define('--params PARAMETERS',
@@ -881,8 +880,10 @@ module Bolt
881
880
  define('--boltdir PATH',
882
881
  'Deprecated. Specify what project to load config from (default:',
883
882
  '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 }
883
+ Bolt::Logger.deprecate(
884
+ "boltdir_cli_option",
885
+ "Command line option '--boltdir' is deprecated, use '--project' instead."
886
+ )
886
887
  @options[:boltdir] = path
887
888
  end
888
889
  define('--project PATH',
@@ -893,10 +894,12 @@ module Bolt
893
894
  'Deprecated. Specify where to load config from (default:',
894
895
  '~/.puppetlabs/bolt/bolt.yaml). Directory containing bolt.yaml will be',
895
896
  'used as the project directory.') do |path|
896
- msg = "Command line option '--configfile' is deprecated, and " \
897
+ Bolt::Logger.deprecate(
898
+ "configfile_cli_option",
899
+ "Command line option '--configfile' is deprecated, and " \
897
900
  "will be removed in Bolt 3.0. Use '--project' and provide the "\
898
901
  "directory path instead."
899
- @deprecations << { type: 'Using --configfile', msg: msg }
902
+ )
900
903
  @options[:configfile] = path
901
904
  end
902
905
  define('--hiera-config PATH',
@@ -915,10 +918,12 @@ module Bolt
915
918
  ' (default: ~/.puppetlabs/bolt/Puppetfile)',
916
919
  'Modules are installed in the current project.') do |path|
917
920
  command = Bolt::Util.powershell? ? 'Update-BoltProject' : 'bolt project migrate'
918
- msg = "Command line option '--puppetfile' is deprecated, and will be removed "\
921
+ Bolt::Logger.deprecate(
922
+ "puppetfile_cli_option",
923
+ "Command line option '--puppetfile' is deprecated, and will be removed "\
919
924
  "in Bolt 3.0. You can migrate to using the new module management "\
920
925
  "workflow using '#{command}'."
921
- @deprecations << { type: 'Using --puppetfile', msg: msg }
926
+ )
922
927
  @options[:puppetfile_path] = File.expand_path(path)
923
928
  end
924
929
  define('--[no-]save-rerun', 'Whether to update the rerun file after this command.') do |save|
@@ -1017,8 +1022,10 @@ module Bolt
1017
1022
  @options[:debug] = true
1018
1023
  # We don't actually set '--log-level debug' here, but once the options are evaluated by
1019
1024
  # 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 }
1025
+ Bolt::Logger.deprecate(
1026
+ "debug_cli_option",
1027
+ "Command line option '--debug' is deprecated, set '--log-level debug' instead."
1028
+ )
1022
1029
  end
1023
1030
  define('--log-level LEVEL',
1024
1031
  "Set the log level for the console. Available options are",
@@ -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
- # Merge plan vars with target vars, while maintaining the order of the plan
83
- # vars. It's critical that the order of plan vars is not changed, as Puppet
84
- # will deserialize the variables in the order they appear. Variables may
85
- # contain local references to variables that appear earlier in a plan. If
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 = { modulepath: request['modulepath'],
91
- facts: target['facts'],
92
- variables: topscope_vars }
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: request['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
 
@@ -147,10 +147,6 @@ module Bolt
147
147
  end
148
148
 
149
149
  validate(options)
150
-
151
- # Deprecation warnings can't be issued until after config is loaded, so
152
- # store them for later.
153
- @parser_deprecations = parser.deprecations
154
150
  rescue Bolt::Error => e
155
151
  fatal_error(e)
156
152
  raise e
@@ -185,20 +181,16 @@ module Bolt
185
181
 
186
182
  # Completes the setup process by configuring Bolt and log messages
187
183
  def finalize_setup
188
- Bolt::Logger.configure(config.log, config.color)
184
+ Bolt::Logger.configure(config.log, config.color, config.disable_warnings)
189
185
  Bolt::Logger.analytics = analytics
186
+ Bolt::Logger.flush_queue
190
187
 
191
188
  # Logger must be configured before checking path case and project file, otherwise logs will not display
192
189
  config.check_path_case('modulepath', config.modulepath)
193
190
  config.project.check_deprecated_file
194
191
 
195
- # Log messages created during parser and config initialization
196
- config.logs.each { |log| @logger.send(log.keys[0], log.values[0]) }
197
- @parser_deprecations.each { |dep| Bolt::Logger.deprecation_warning(dep[:type], dep[:msg]) }
198
- config.deprecations.each { |dep| Bolt::Logger.deprecation_warning(dep[:type], dep[:msg]) }
199
-
200
- if options[:clear_cache] && File.exist?(config.project.cache_file)
201
- FileUtils.rm(config.project.cache_file)
192
+ if options[:clear_cache] && File.exist?(config.project.plugin_cache_file)
193
+ FileUtils.rm(config.project.plugin_cache_file)
202
194
  end
203
195
 
204
196
  warn_inventory_overrides_cli(options)
@@ -212,12 +204,15 @@ module Bolt
212
204
 
213
205
  private def validate_ps_version
214
206
  if Bolt::Util.powershell?
215
- target = inventory.get_target('localhost')
216
- Bolt::Transport::Local.new.with_connection(target) do |conn|
217
- # This will automatically validate the powershell version on the Bolt
218
- # controller
219
- Bolt::Shell::Powershell.new(target, conn)
220
- end
207
+ command = "powershell.exe -NoProfile -NonInteractive -NoLogo -ExecutionPolicy "\
208
+ "Bypass -Command $PSVersionTable.PSVersion.Major"
209
+ stdout, _stderr, _status = Open3.capture3(command)
210
+
211
+ return unless !stdout.empty? && stdout.to_i < 3
212
+
213
+ msg = "Detected PowerShell 2 on controller. PowerShell 2 is deprecated and "\
214
+ "support will be removed in Bolt 3.0."
215
+ Bolt::Logger.deprecate("powershell_2_controller", msg)
221
216
  end
222
217
  end
223
218
 
@@ -373,7 +368,10 @@ module Bolt
373
368
  conflicting_options = Set.new(opts.keys.map(&:to_s)).intersection(inventory_cli_opts)
374
369
 
375
370
  if inventory_source && conflicting_options.any?
376
- @logger.warn("CLI arguments #{conflicting_options.to_a} may be overridden by Inventory: #{inventory_source}")
371
+ Bolt::Logger.warn(
372
+ "cli_overrides",
373
+ "CLI arguments #{conflicting_options.to_a} may be overridden by Inventory: #{inventory_source}"
374
+ )
377
375
  end
378
376
  end
379
377
 
@@ -491,9 +489,9 @@ module Bolt
491
489
  when 'module'
492
490
  case options[:action]
493
491
  when 'add'
494
- code = add_project_module(options[:object], config.project)
492
+ code = add_project_module(options[:object], config.project, config.module_install)
495
493
  when 'install'
496
- code = install_project_modules(config.project, options[:force], options[:resolve])
494
+ code = install_project_modules(config.project, config.module_install, options[:force], options[:resolve])
497
495
  when 'generate-types'
498
496
  code = generate_types
499
497
  end
@@ -604,7 +602,7 @@ module Bolt
604
602
  end
605
603
 
606
604
  def list_plans
607
- plans = filter_content(pal.list_plans(filter_content: true), options[:filter])
605
+ plans = filter_content(pal.list_plans_with_cache(filter_content: true), options[:filter])
608
606
  outputter.print_plans(plans, pal.user_modulepath)
609
607
  end
610
608
 
@@ -656,7 +654,7 @@ module Bolt
656
654
  if node_param && target_param
657
655
  msg = "Plan parameters include both 'nodes' and 'targets' with type 'TargetSpec', " \
658
656
  "neither will populated with the value for --nodes or --targets."
659
- @logger.warn(msg)
657
+ Bolt::Logger.warn("nodes_targets_parameters", msg)
660
658
  elsif node_param
661
659
  plan_arguments['nodes'] = nodes.join(',')
662
660
  elsif target_param
@@ -701,7 +699,7 @@ module Bolt
701
699
  "about defining and declaring classes and types in the Puppet documentation at "\
702
700
  "https://puppet.com/docs/puppet/latest/lang_classes.html and "\
703
701
  "https://puppet.com/docs/puppet/latest/lang_defined_types.html"
704
- @logger.warn(message)
702
+ Bolt::Logger.warn("empty_manifest", message)
705
703
  end
706
704
 
707
705
  executor = Bolt::Executor.new(config.concurrency, analytics, noop, config.modified_concurrency)
@@ -737,13 +735,13 @@ module Bolt
737
735
  def generate_types
738
736
  assert_puppetfile_or_module_command(config.project.modules)
739
737
  # generate_types will surface a nice error with helpful message if it fails
740
- pal.generate_types
738
+ pal.generate_types(cache: true)
741
739
  0
742
740
  end
743
741
 
744
742
  # Installs modules declared in the project configuration file.
745
743
  #
746
- def install_project_modules(project, force, resolve)
744
+ def install_project_modules(project, config, force, resolve)
747
745
  assert_project_file(project)
748
746
  assert_puppetfile_or_module_command(project.modules)
749
747
 
@@ -753,30 +751,39 @@ module Bolt
753
751
  return 0
754
752
  end
755
753
 
754
+ modules = project.modules || []
756
755
  installer = Bolt::ModuleInstaller.new(outputter, pal)
757
756
 
758
- ok = installer.install(project.modules,
759
- project.puppetfile,
760
- project.managed_moduledir,
761
- force: force,
762
- resolve: resolve)
757
+ ok = outputter.spin do
758
+ installer.install(modules,
759
+ project.puppetfile,
760
+ project.managed_moduledir,
761
+ config,
762
+ force: force,
763
+ resolve: resolve)
764
+ end
765
+
763
766
  ok ? 0 : 1
764
767
  end
765
768
 
766
769
  # Adds a single module to the project.
767
770
  #
768
- def add_project_module(name, project)
771
+ def add_project_module(name, project, config)
769
772
  assert_project_file(project)
770
773
  assert_puppetfile_or_module_command(project.modules)
771
774
 
772
775
  modules = project.modules || []
773
776
  installer = Bolt::ModuleInstaller.new(outputter, pal)
774
777
 
775
- ok = installer.add(name,
776
- modules,
777
- project.puppetfile,
778
- project.managed_moduledir,
779
- project.project_file)
778
+ ok = outputter.spin do
779
+ installer.add(name,
780
+ modules,
781
+ project.puppetfile,
782
+ project.managed_moduledir,
783
+ project.project_file,
784
+ config)
785
+ end
786
+
780
787
  ok ? 0 : 1
781
788
  end
782
789
 
@@ -805,7 +812,10 @@ module Bolt
805
812
 
806
813
  outputter.print_message("Installing modules from Puppetfile")
807
814
  installer = Bolt::ModuleInstaller.new(outputter, pal)
808
- ok = installer.install_puppetfile(puppetfile, moduledir, puppetfile_config)
815
+ ok = outputter.spin do
816
+ installer.install_puppetfile(puppetfile, moduledir, puppetfile_config)
817
+ end
818
+
809
819
  ok ? 0 : 1
810
820
  end
811
821
 
@@ -838,6 +848,10 @@ module Bolt
838
848
  raise Bolt::CLIError,
839
849
  "Unable to use command '#{old_command}' when 'modules' is configured in "\
840
850
  "bolt-project.yaml. Use '#{new_command}' instead."
851
+ elsif modules.nil? && options[:subcommand] == 'puppetfile'
852
+ msg = "Command '#{old_command}' is deprecated and will be removed in Bolt 3.0. Update your project to use "\
853
+ "the module management feature. For more information, see https://pup.pt/bolt-module-migrate."
854
+ Bolt::Logger.deprecate("puppetfile_command", msg)
841
855
  elsif modules.nil? && options[:subcommand] == 'module'
842
856
  msg = "Unable to use command '#{new_command}' when 'modules' is not configured in "\
843
857
  "bolt-project.yaml. "
@@ -911,7 +925,11 @@ module Bolt
911
925
  end
912
926
 
913
927
  def outputter
914
- @outputter ||= Bolt::Outputter.for_format(config.format, config.color, options[:verbose], config.trace)
928
+ @outputter ||= Bolt::Outputter.for_format(config.format,
929
+ config.color,
930
+ options[:verbose],
931
+ config.trace,
932
+ config.spinner)
915
933
  end
916
934
 
917
935
  def log_outputter
@@ -938,7 +956,7 @@ module Bolt
938
956
  set the BOLT_GEM environment variable.
939
957
  MSG
940
958
 
941
- @logger.warn(msg)
959
+ Bolt::Logger.warn("gem_install", msg)
942
960
  end
943
961
 
944
962
  # We only need to enumerate bundled content when running a task or plan