bolt 2.40.2 → 3.1.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +19 -17
  3. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +25 -0
  4. data/bolt-modules/boltlib/lib/puppet/functions/parallelize.rb +6 -8
  5. data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +7 -3
  6. data/lib/bolt/analytics.rb +3 -2
  7. data/lib/bolt/applicator.rb +11 -1
  8. data/lib/bolt/bolt_option_parser.rb +3 -113
  9. data/lib/bolt/catalog.rb +10 -29
  10. data/lib/bolt/cli.rb +54 -155
  11. data/lib/bolt/config.rb +62 -239
  12. data/lib/bolt/config/options.rb +58 -97
  13. data/lib/bolt/config/transport/local.rb +1 -0
  14. data/lib/bolt/config/transport/options.rb +8 -1
  15. data/lib/bolt/config/transport/orch.rb +1 -0
  16. data/lib/bolt/executor.rb +15 -5
  17. data/lib/bolt/inventory.rb +3 -2
  18. data/lib/bolt/inventory/group.rb +35 -4
  19. data/lib/bolt/inventory/inventory.rb +1 -1
  20. data/lib/bolt/logger.rb +115 -11
  21. data/lib/bolt/module.rb +10 -2
  22. data/lib/bolt/module_installer.rb +4 -2
  23. data/lib/bolt/module_installer/resolver.rb +65 -12
  24. data/lib/bolt/module_installer/specs/forge_spec.rb +8 -2
  25. data/lib/bolt/module_installer/specs/git_spec.rb +17 -2
  26. data/lib/bolt/outputter/human.rb +9 -5
  27. data/lib/bolt/outputter/json.rb +16 -16
  28. data/lib/bolt/outputter/rainbow.rb +3 -3
  29. data/lib/bolt/pal.rb +94 -14
  30. data/lib/bolt/pal/yaml_plan.rb +8 -2
  31. data/lib/bolt/pal/yaml_plan/evaluator.rb +7 -19
  32. data/lib/bolt/pal/yaml_plan/step.rb +3 -24
  33. data/lib/bolt/pal/yaml_plan/step/upload.rb +2 -2
  34. data/lib/bolt/pal/yaml_plan/transpiler.rb +6 -1
  35. data/lib/bolt/plugin.rb +3 -3
  36. data/lib/bolt/plugin/cache.rb +7 -7
  37. data/lib/bolt/plugin/module.rb +0 -23
  38. data/lib/bolt/plugin/puppet_connect_data.rb +77 -0
  39. data/lib/bolt/plugin/puppetdb.rb +1 -1
  40. data/lib/bolt/project.rb +54 -81
  41. data/lib/bolt/project_manager.rb +4 -3
  42. data/lib/bolt/project_manager/module_migrator.rb +6 -5
  43. data/lib/bolt/rerun.rb +1 -1
  44. data/lib/bolt/result.rb +6 -1
  45. data/lib/bolt/shell/bash.rb +9 -4
  46. data/lib/bolt/shell/bash/tmpdir.rb +4 -1
  47. data/lib/bolt/shell/powershell.rb +9 -5
  48. data/lib/bolt/shell/powershell/snippets.rb +37 -150
  49. data/lib/bolt/task.rb +1 -1
  50. data/lib/bolt/transport/base.rb +0 -9
  51. data/lib/bolt/transport/docker.rb +1 -125
  52. data/lib/bolt/transport/docker/connection.rb +86 -161
  53. data/lib/bolt/transport/local.rb +1 -9
  54. data/lib/bolt/transport/orch/connection.rb +1 -1
  55. data/lib/bolt/transport/ssh.rb +1 -2
  56. data/lib/bolt/transport/ssh/connection.rb +1 -1
  57. data/lib/bolt/validator.rb +2 -2
  58. data/lib/bolt/version.rb +1 -1
  59. data/lib/bolt_server/config.rb +1 -1
  60. data/lib/bolt_server/transport_app.rb +48 -31
  61. data/lib/bolt_spec/bolt_context.rb +9 -4
  62. data/lib/bolt_spec/plans.rb +1 -109
  63. data/libexec/bolt_catalog +1 -1
  64. data/modules/aggregate/plans/count.pp +21 -0
  65. data/modules/aggregate/plans/targets.pp +21 -0
  66. data/modules/puppet_connect/plans/test_input_data.pp +67 -0
  67. data/modules/puppetdb_fact/plans/init.pp +10 -0
  68. metadata +28 -19
  69. data/modules/aggregate/plans/nodes.pp +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1b59f916303bbd38bb82a011ecff7a2e5086094586cea84d4cd78fb052d2171
4
- data.tar.gz: 425288bb47b49aa017d71ee0b2bb1e48de475980f70e14be11f369acadfd0582
3
+ metadata.gz: fb26f585ef72c98683208ddbed3f04cfeb20a035a252604bf73927354ccae4ba
4
+ data.tar.gz: ad2f911f3e960a4c8ae42586c68466f8526d454d8b227391ac8032614176baa7
5
5
  SHA512:
6
- metadata.gz: dc56fc52b8e52553902316fb26204a89a90901a9cf56e13d9ff8a1f2d4aea96d1054d578bda7598ba38384baf424a751230038bd8c6c593b113854a176cafeb7
7
- data.tar.gz: 07a33c2ea3d3fdf5f69e9844d7c45dbb88cfedfabd8ce9264408876ee7496568033d372128eba510431bbb749c4223a8ba5420941936f2efd304ded398c90ad0
6
+ metadata.gz: aa283cf489870b48c9b44098c6f4cd0b805ac963c86369481dae603997a3dd150025273ca9168a6c93538ee60acbcfca16fa524951a6e6dcc59a61212d682da9
7
+ data.tar.gz: cd7b62972011560ac21404e0589169f0ab690faaa7f17b8138bc09ad30637ac66fb1823f21714ea30c7526c637c7fec89e3d4fe237ad1ca753a6c1c7f46cc56c
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,26 +22,28 @@ mod 'puppetlabs-yumrepo_core', '1.0.7'
22
22
  mod 'puppetlabs-zone_core', '1.0.3'
23
23
 
24
24
  # Useful additional modules
25
- mod 'puppetlabs-package', '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'
31
- mod 'puppetlabs-stdlib', '6.5.0'
25
+ mod 'puppetlabs-package', '1.4.0'
26
+ mod 'puppetlabs-powershell_task_helper', '0.1.0'
27
+ mod 'puppetlabs-puppet_conf', '0.8.0'
28
+ mod 'puppetlabs-python_task_helper', '0.5.0'
29
+ mod 'puppetlabs-reboot', '3.2.0'
30
+ mod 'puppetlabs-ruby_task_helper', '0.6.0'
31
+ mod 'puppetlabs-ruby_plugin_helper', '0.2.0'
32
+ mod 'puppetlabs-stdlib', '6.6.0'
32
33
 
33
34
  # 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'
35
+ mod 'puppetlabs-aws_inventory', '0.6.0'
36
+ mod 'puppetlabs-azure_inventory', '0.5.0'
37
+ mod 'puppetlabs-gcloud_inventory', '0.2.0'
37
38
  mod 'puppetlabs-http_request', '0.2.1'
38
39
  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'
40
+ mod 'puppetlabs-secure_env_vars', '0.2.0'
41
+ mod 'puppetlabs-terraform', '0.6.1'
42
+ mod 'puppetlabs-vault', '0.4.0'
42
43
  mod 'puppetlabs-yaml', '0.2.0'
43
44
 
44
45
  # If we don't list these modules explicitly, r10k will purge them
45
46
  mod 'canary', local: true
46
47
  mod 'aggregate', local: true
47
48
  mod 'puppetdb_fact', local: true
49
+ mod 'puppet_connect', local: true
@@ -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 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
@@ -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
@@ -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
@@ -6,15 +6,15 @@ require 'optparse'
6
6
 
7
7
  module Bolt
8
8
  class BoltOptionParser < OptionParser
9
- PROJECT_PATHS = %w[project configfile boltdir].freeze
10
- OPTIONS = { inventory: %w[targets query rerun description],
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 debug log-level clear-cache] }.freeze
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
- # 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