bolt 1.49.0 → 2.0.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/Puppetfile +6 -6
  3. data/bolt-modules/boltlib/lib/puppet/datatypes/target.rb +24 -45
  4. data/bolt-modules/boltlib/lib/puppet/functions/add_facts.rb +3 -3
  5. data/bolt-modules/boltlib/lib/puppet/functions/add_to_group.rb +1 -1
  6. data/bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb +10 -12
  7. data/bolt-modules/boltlib/lib/puppet/functions/catch_errors.rb +1 -1
  8. data/bolt-modules/boltlib/lib/puppet/functions/fail_plan.rb +3 -3
  9. data/bolt-modules/boltlib/lib/puppet/functions/get_resources.rb +5 -4
  10. data/bolt-modules/boltlib/lib/puppet/functions/get_target.rb +1 -3
  11. data/bolt-modules/boltlib/lib/puppet/functions/get_targets.rb +1 -2
  12. data/bolt-modules/boltlib/lib/puppet/functions/puppetdb_fact.rb +2 -2
  13. data/bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb +2 -2
  14. data/bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb +1 -1
  15. data/bolt-modules/boltlib/lib/puppet/functions/run_command.rb +7 -3
  16. data/bolt-modules/boltlib/lib/puppet/functions/run_plan.rb +15 -31
  17. data/bolt-modules/boltlib/lib/puppet/functions/run_script.rb +9 -5
  18. data/bolt-modules/boltlib/lib/puppet/functions/run_task.rb +9 -3
  19. data/bolt-modules/boltlib/lib/puppet/functions/set_config.rb +4 -3
  20. data/bolt-modules/boltlib/lib/puppet/functions/set_feature.rb +6 -6
  21. data/bolt-modules/boltlib/lib/puppet/functions/set_var.rb +2 -2
  22. data/bolt-modules/boltlib/lib/puppet/functions/upload_file.rb +7 -3
  23. data/bolt-modules/boltlib/lib/puppet/functions/wait_until_available.rb +6 -2
  24. data/bolt-modules/boltlib/lib/puppet/functions/without_default_logging.rb +2 -2
  25. data/bolt-modules/ctrl/lib/puppet/functions/ctrl/do_until.rb +2 -1
  26. data/bolt-modules/file/lib/puppet/functions/file/exists.rb +2 -1
  27. data/bolt-modules/file/lib/puppet/functions/file/join.rb +1 -0
  28. data/bolt-modules/file/lib/puppet/functions/file/read.rb +1 -0
  29. data/bolt-modules/file/lib/puppet/functions/file/readable.rb +2 -1
  30. data/bolt-modules/out/lib/puppet/functions/out/message.rb +1 -1
  31. data/bolt-modules/system/lib/puppet/functions/system/env.rb +1 -0
  32. data/lib/bolt/applicator.rb +70 -118
  33. data/lib/bolt/apply_target.rb +1 -1
  34. data/lib/bolt/bolt_option_parser.rb +21 -37
  35. data/lib/bolt/catalog.rb +5 -22
  36. data/lib/bolt/catalog/logging.rb +1 -1
  37. data/lib/bolt/cli.rb +33 -44
  38. data/lib/bolt/config.rb +15 -18
  39. data/lib/bolt/error.rb +2 -2
  40. data/lib/bolt/executor.rb +32 -40
  41. data/lib/bolt/inventory.rb +9 -367
  42. data/lib/bolt/inventory/group.rb +293 -182
  43. data/lib/bolt/inventory/{inventory2.rb → inventory.rb} +25 -14
  44. data/lib/bolt/inventory/target.rb +1 -1
  45. data/lib/bolt/module.rb +4 -4
  46. data/lib/bolt/outputter/human.rb +11 -6
  47. data/lib/bolt/outputter/json.rb +3 -11
  48. data/lib/bolt/pal.rb +1 -2
  49. data/lib/bolt/pal/yaml_plan/step/resources.rb +1 -1
  50. data/lib/bolt/plugin.rb +1 -1
  51. data/lib/bolt/plugin/module.rb +19 -36
  52. data/lib/bolt/plugin/prompt.rb +2 -4
  53. data/lib/bolt/puppetdb/config.rb +1 -3
  54. data/lib/bolt/result.rb +3 -6
  55. data/lib/bolt/secret/base.rb +0 -6
  56. data/lib/bolt/target.rb +8 -219
  57. data/lib/bolt/transport/local/shell.rb +9 -13
  58. data/lib/bolt/transport/orch.rb +3 -5
  59. data/lib/bolt/transport/ssh.rb +1 -0
  60. data/lib/bolt/transport/ssh/connection.rb +1 -4
  61. data/lib/bolt/transport/winrm/connection.rb +1 -1
  62. data/lib/bolt/util.rb +2 -8
  63. data/lib/bolt/version.rb +1 -1
  64. data/lib/bolt_server/transport_app.rb +35 -17
  65. data/lib/bolt_spec/plans.rb +8 -2
  66. data/libexec/bolt_catalog +19 -5
  67. metadata +4 -8
  68. data/exe/bolt-inventory-pdb +0 -13
  69. data/lib/bolt/inventory/group2.rb +0 -403
  70. data/lib/bolt_ext/puppetdb_inventory.rb +0 -129
@@ -7,12 +7,15 @@ require 'bolt/task'
7
7
  # Runs a given instance of a `Task` on the given set of targets and returns the result from each.
8
8
  # This function does nothing if the list of targets is empty.
9
9
  #
10
- # **NOTE:** Not available in apply block
10
+ # > **Note:** Not available in apply block
11
11
  Puppet::Functions.create_function(:run_task) do
12
12
  # Run a task.
13
13
  # @param task_name The task to run.
14
14
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
15
- # @param args Arguments to the plan. Can also include additional options: '_catch_errors', '_run_as', '_noop'.
15
+ # @param args A hash of arguments to the task. Can also include additional options.
16
+ # @option args [Boolean] _catch_errors Whether to catch raised errors.
17
+ # @option args [String] _run_as User to run as using privilege escalation.
18
+ # @option args [Boolean] _noop Run the task in noop mode if available.
16
19
  # @return A list of results, one entry per target.
17
20
  # @example Run a task as root
18
21
  # run_task('facts', $targets, '_run_as' => 'root')
@@ -27,7 +30,10 @@ Puppet::Functions.create_function(:run_task) do
27
30
  # @param task_name The task to run.
28
31
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
29
32
  # @param description A description to be output when calling this function.
30
- # @param args Arguments to the plan. Can also include additional options: '_catch_errors', '_run_as', '_noop'.
33
+ # @param args A hash of arguments to the task. Can also include additional options.
34
+ # @option args [Boolean] _catch_errors Whether to catch raised errors.
35
+ # @option args [String] _run_as User to run as using privilege escalation.
36
+ # @option args [Boolean] _noop Run the task in noop mode if available.
31
37
  # @return A list of results, one entry per target.
32
38
  # @example Run a task
33
39
  # run_task('facts', $targets, 'Gather OS facts')
@@ -2,10 +2,11 @@
2
2
 
3
3
  require 'bolt/error'
4
4
 
5
- # Set configuration options on a target
5
+ # Set configuration options on a target.
6
6
  #
7
- # **NOTE:** Not available in apply block
8
- # **NOTE:** Only compatible with inventory v2
7
+ # > **Note:** Not available in apply block
8
+ #
9
+ # > **Note:** Only compatible with inventory v2
9
10
  Puppet::Functions.create_function(:set_config) do
10
11
  # @param target The Target object to configure. See {get_targets}.
11
12
  # @param key_or_key_path The configuration setting to update.
@@ -5,18 +5,18 @@ require 'bolt/error'
5
5
  # Sets a particular feature to present on a target.
6
6
  #
7
7
  # Features are used to determine what implementation of a task should be run.
8
- # Currently supported features are
9
- # - powershell
10
- # - shell
11
- # - puppet-agent
8
+ # Supported features are:
9
+ # - `powershell`
10
+ # - `shell`
11
+ # - `puppet-agent`
12
12
  #
13
- # **NOTE:** Not available in apply block
13
+ # > **Note:** Not available in apply block
14
14
  Puppet::Functions.create_function(:set_feature) do
15
15
  # @param target The Target object to add features to. See {get_targets}.
16
16
  # @param feature The string identifying the feature.
17
17
  # @param value Whether the feature is supported.
18
18
  # @return The target with the updated feature
19
- # @example Add the puppet-agent feature to a target
19
+ # @example Add the `puppet-agent` feature to a target
20
20
  # set_feature($target, 'puppet-agent', true)
21
21
  dispatch :set_feature do
22
22
  param 'Target', :target
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'bolt/error'
4
4
 
5
- # Sets a variable { key => value } for a target.
5
+ # Sets a variable `{ key => value }` for a target.
6
6
  #
7
- # **NOTE:** Not available in apply block
7
+ # > **Note:** Not available in apply block
8
8
  Puppet::Functions.create_function(:set_var) do
9
9
  # @param target The Target object to set the variable for. See {get_targets}.
10
10
  # @param key The key for the variable.
@@ -5,14 +5,16 @@ require 'bolt/error'
5
5
  # Uploads the given file or directory to the given set of targets and returns the result from each upload.
6
6
  # This function does nothing if the list of targets is empty.
7
7
  #
8
- # **NOTE:** Not available in apply block
8
+ # > **Note:** Not available in apply block
9
9
  Puppet::Functions.create_function(:upload_file, Puppet::Functions::InternalFunction) do
10
10
  # Upload a file or directory.
11
11
  # @param source A source path, either an absolute path or a modulename/filename selector for a
12
12
  # file or directory in $MODULEROOT/files.
13
13
  # @param destination An absolute path on the target(s).
14
14
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
15
- # @param options Additional options: '_catch_errors', '_run_as'.
15
+ # @param options A hash of additional options.
16
+ # @option options [Boolean] _catch_errors Whether to catch raised errors.
17
+ # @option options [String] _run_as User to run as using privilege escalation.
16
18
  # @return A list of results, one entry per target.
17
19
  # @example Upload a local file to Linux targets and change owner to 'root'
18
20
  # upload_file('/var/tmp/payload.tgz', '/tmp/payload.tgz', $targets, '_run_as' => 'root')
@@ -33,7 +35,9 @@ Puppet::Functions.create_function(:upload_file, Puppet::Functions::InternalFunct
33
35
  # @param destination An absolute path on the target(s).
34
36
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
35
37
  # @param description A description to be output when calling this function.
36
- # @param options Additional options: '_catch_errors', '_run_as'.
38
+ # @param options A hash of additional options.
39
+ # @option options [Boolean] _catch_errors Whether to catch raised errors.
40
+ # @option options [String] _run_as User to run as using privilege escalation.
37
41
  # @return A list of results, one entry per target.
38
42
  # @example Upload a file
39
43
  # upload_file('/var/tmp/payload.tgz', '/tmp/payload.tgz', $targets, 'Uploading payload to unpack')
@@ -4,11 +4,15 @@ require 'bolt/util'
4
4
 
5
5
  # Wait until all targets accept connections.
6
6
  #
7
- # **NOTE:** Not available in apply block
7
+ # > **Note:** Not available in apply block
8
8
  Puppet::Functions.create_function(:wait_until_available) do
9
9
  # Wait until targets are available.
10
10
  # @param targets A pattern identifying zero or more targets. See {get_targets} for accepted patterns.
11
- # @param options Additional options: 'description', 'wait_time', 'retry_interval', '_catch_errors'.
11
+ # @param options A hash of additional options.
12
+ # @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)
15
+ # @option options [Boolean] _catch_errors Whether to catch raised errors.
12
16
  # @return A list of results, one entry per target. Successful results have no value.
13
17
  # @example Wait for targets
14
18
  # wait_until_available($targets, wait_time => 300)
@@ -3,10 +3,10 @@
3
3
  # Define a block where default logging is suppressed.
4
4
  #
5
5
  # Messages for actions within this block will be logged at `info` level instead
6
- # of `notice`, so they will not be seen normally but # will still be present
6
+ # of `notice`, so they will not be seen normally but will still be present
7
7
  # when `verbose` logging is requested.
8
8
  #
9
- # **NOTE:** Not available in apply block
9
+ # > **Note:** Not available in apply block
10
10
  Puppet::Functions.create_function(:without_default_logging) do
11
11
  # @param block The block where action logging is suppressed.
12
12
  # @return [Undef]
@@ -2,7 +2,8 @@
2
2
 
3
3
  # Repeat the block until it returns a truthy value. Returns the value.
4
4
  Puppet::Functions.create_function(:'ctrl::do_until') do
5
- # @param options Additional options: 'until'
5
+ # @param options A hash of additional options.
6
+ # @option options [Numeric] limit The number of times to repeat the block.
6
7
  # @example Run a task until it succeeds
7
8
  # ctrl::do_until() || {
8
9
  # run_task('test', $target, _catch_errors => true).ok()
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # check if a file exists
3
+ # Check if a file exists.
4
4
  Puppet::Functions.create_function(:'file::exists', Puppet::Functions::InternalFunction) do
5
5
  # @param filename Absolute path or Puppet file path.
6
+ # @return Whether the file exists.
6
7
  # @example Check a file on disk
7
8
  # file::exists('/tmp/i_dumped_this_here')
8
9
  # @example check a file from the modulepath
@@ -3,6 +3,7 @@
3
3
  # Join file paths.
4
4
  Puppet::Functions.create_function(:'file::join') do
5
5
  # @param paths The paths to join.
6
+ # @return The joined file path.
6
7
  # @example Join file paths
7
8
  # file::join('./path', 'to/files')
8
9
  dispatch :join do
@@ -3,6 +3,7 @@
3
3
  # Read a file and return its contents.
4
4
  Puppet::Functions.create_function(:'file::read', Puppet::Functions::InternalFunction) do
5
5
  # @param filename Absolute path or Puppet file path.
6
+ # @return The file's contents.
6
7
  # @example Read a file from disk
7
8
  # file::read('/tmp/i_dumped_this_here')
8
9
  # @example Read a file from the modulepath
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # check if a file is readable
3
+ # Check if a file is readable.
4
4
  Puppet::Functions.create_function(:'file::readable', Puppet::Functions::InternalFunction) do
5
5
  # @param filename Absolute path or Puppet file path.
6
+ # @return Whether the file is readable.
6
7
  # @example Check a file on disk
7
8
  # file::readable('/tmp/i_dumped_this_here')
8
9
  # @example check a file from the modulepath
@@ -5,7 +5,7 @@
5
5
  # This will print a message to stdout when using the human output format,
6
6
  # and print to stderr when using the json output format
7
7
  #
8
- # **NOTE:** Not available in apply block
8
+ # > **Note:** Not available in apply block
9
9
  Puppet::Functions.create_function(:'out::message') do
10
10
  # Output a message.
11
11
  # @param message The message to output.
@@ -3,6 +3,7 @@
3
3
  # Get an environment variable.
4
4
  Puppet::Functions.create_function(:'system::env') do
5
5
  # @param name Environment variable name.
6
+ # @return The environment variable's value.
6
7
  # @example Get the USER environment variable
7
8
  # system::env('USER')
8
9
  dispatch :env do
@@ -83,60 +83,7 @@ module Bolt
83
83
  end
84
84
  end
85
85
 
86
- def compile(target, ast, plan_vars)
87
- # This simplified Puppet node object is what .local uses to determine the
88
- # certname of the target
89
- node = Puppet::Node.from_data_hash('name' => target.name,
90
- 'parameters' => { 'clientcert' => target.name })
91
- trusted = Puppet::Context::TrustedInformation.local(node)
92
- facts = @inventory.facts(target).merge('bolt' => true)
93
-
94
- catalog_input = {
95
- code_ast: ast,
96
- modulepath: @modulepath,
97
- pdb_config: @pdb_client.config.to_hash,
98
- hiera_config: @hiera_config,
99
- target: {
100
- name: target.name,
101
- facts: facts,
102
- variables: @inventory.vars(target).merge(plan_vars),
103
- trusted: trusted.to_h
104
- },
105
- inventory: @inventory.data_hash
106
- }
107
-
108
- bolt_catalog_exe = File.join(libexec, 'bolt_catalog')
109
- old_path = ENV['PATH']
110
- ENV['PATH'] = "#{RbConfig::CONFIG['bindir']}#{File::PATH_SEPARATOR}#{old_path}"
111
- out, err, stat = Open3.capture3('ruby', bolt_catalog_exe, 'compile', stdin_data: catalog_input.to_json)
112
- ENV['PATH'] = old_path
113
-
114
- # stderr may contain formatted logs from Puppet's logger or other errors.
115
- # Print them in order, but handle them separately. Anything not a formatted log is assumed
116
- # to be an error message.
117
- logs = err.lines.map do |l|
118
- begin
119
- JSON.parse(l)
120
- rescue StandardError
121
- l
122
- end
123
- end
124
- logs.each do |log|
125
- if log.is_a?(String)
126
- @logger.error(log.chomp)
127
- else
128
- log.map { |k, v| [k.to_sym, v] }.each do |level, msg|
129
- bolt_level = Bolt::Util::PuppetLogLevel::MAPPING[level]
130
- @logger.send(bolt_level, "#{target.name}: #{msg.chomp}")
131
- end
132
- end
133
- end
134
-
135
- raise(ApplyError, target.name) unless stat.success?
136
- JSON.parse(out)
137
- end
138
-
139
- def future_compile(target, catalog_input)
86
+ def compile(target, catalog_input)
140
87
  # This simplified Puppet node object is what .local uses to determine the
141
88
  # certname of the target
142
89
  node = Puppet::Node.from_data_hash('name' => target.name,
@@ -148,9 +95,6 @@ module Bolt
148
95
  variables: @inventory.vars(target),
149
96
  trusted: trusted.to_h
150
97
  }
151
- # rubocop:disable Style/GlobalVars
152
- catalog_input[:future] = $future
153
- # rubocop:enable Style/GlobalVars
154
98
 
155
99
  bolt_catalog_exe = File.join(libexec, 'bolt_catalog')
156
100
  old_path = ENV['PATH']
@@ -158,29 +102,30 @@ module Bolt
158
102
  out, err, stat = Open3.capture3('ruby', bolt_catalog_exe, 'compile', stdin_data: catalog_input.to_json)
159
103
  ENV['PATH'] = old_path
160
104
 
161
- # stderr may contain formatted logs from Puppet's logger or other errors.
162
- # Print them in order, but handle them separately. Anything not a formatted log is assumed
163
- # to be an error message.
164
- logs = err.lines.map do |l|
165
- begin
166
- JSON.parse(l)
167
- rescue StandardError
168
- l
169
- end
105
+ # Any messages logged by Puppet will be on stderr as JSON hashes, so we
106
+ # parse those and store them here. Any message on stderr that is not
107
+ # properly JSON formatted is assumed to be an error message. If
108
+ # compilation was successful, we print the logs as they may include
109
+ # important warnings. If compilation failed, we don't print the logs as
110
+ # they are likely redundant with the error that caused the failure, which
111
+ # will be handled separately.
112
+ logs = err.lines.map do |line|
113
+ JSON.parse(line)
114
+ rescue JSON::ParserError
115
+ { 'level' => 'err', 'message' => line }
170
116
  end
171
- logs.each do |log|
172
- if log.is_a?(String)
173
- @logger.error(log.chomp)
174
- else
175
- log.map { |k, v| [k.to_sym, v] }.each do |level, msg|
176
- bolt_level = Bolt::Util::PuppetLogLevel::MAPPING[level]
177
- @logger.send(bolt_level, "#{target.name}: #{msg.chomp}")
178
- end
117
+
118
+ result = JSON.parse(out)
119
+ if stat.success?
120
+ logs.each do |log|
121
+ bolt_level = Bolt::Util::PuppetLogLevel::MAPPING[log['level'].to_sym]
122
+ message = log['message'].chomp
123
+ @logger.send(bolt_level, "#{target.name}: #{message}")
179
124
  end
125
+ result
126
+ else
127
+ raise ApplyError.new(target.name, result['message'])
180
128
  end
181
-
182
- raise(ApplyError, target.name) unless stat.success?
183
- JSON.parse(out)
184
129
  end
185
130
 
186
131
  def validate_hiera_config(hiera_config)
@@ -232,25 +177,22 @@ module Bolt
232
177
  def apply_ast(raw_ast, targets, options, plan_vars = {})
233
178
  ast = Puppet::Pops::Serialization::ToDataConverter.convert(raw_ast, rich_data: true, symbol_to_string: true)
234
179
 
235
- # rubocop:disable Style/GlobalVars
236
- if $future
237
- # Serialize as pcore for *Result* objects
238
- plan_vars = Puppet::Pops::Serialization::ToDataConverter.convert(plan_vars,
239
- rich_data: true,
240
- symbol_as_string: true,
241
- type_by_reference: true,
242
- local_reference: false)
243
- scope = {
244
- code_ast: ast,
245
- modulepath: @modulepath,
246
- pdb_config: @pdb_client.config.to_hash,
247
- hiera_config: @hiera_config,
248
- plan_vars: plan_vars,
249
- # This data isn't available on the target config hash
250
- config: @inventory.config.transport_data_get
251
- }
252
- end
253
- # rubocop:enable Style/GlobalVars
180
+ # Serialize as pcore for *Result* objects
181
+ plan_vars = Puppet::Pops::Serialization::ToDataConverter.convert(plan_vars,
182
+ rich_data: true,
183
+ symbol_as_string: true,
184
+ type_by_reference: true,
185
+ local_reference: false)
186
+
187
+ scope = {
188
+ code_ast: ast,
189
+ modulepath: @modulepath,
190
+ pdb_config: @pdb_client.config.to_hash,
191
+ hiera_config: @hiera_config,
192
+ plan_vars: plan_vars,
193
+ # This data isn't available on the target config hash
194
+ config: @inventory.config.transport_data_get
195
+ }
254
196
 
255
197
  description = options[:description] || 'apply catalog'
256
198
 
@@ -258,9 +200,7 @@ module Bolt
258
200
  futures = targets.map do |target|
259
201
  Concurrent::Future.execute(executor: @pool) do
260
202
  @executor.with_node_logging("Compiling manifest block", [target]) do
261
- # rubocop:disable Style/GlobalVars
262
- $future ? future_compile(target, scope) : compile(target, ast, plan_vars)
263
- # rubocop:enable Style/GlobalVars
203
+ compile(target, scope)
264
204
  end
265
205
  end
266
206
  end
@@ -269,27 +209,39 @@ module Bolt
269
209
  @executor.queue_execute([target]) do |transport, batch|
270
210
  @executor.with_node_logging("Applying manifest block", batch) do
271
211
  catalog = future.value
272
- raise future.reason if future.rejected?
273
-
274
- arguments = {
275
- 'catalog' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(catalog),
276
- 'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins),
277
- 'apply_settings' => @apply_settings,
278
- '_task' => catalog_apply_task.name,
279
- '_noop' => options[:noop]
280
- }
281
-
282
- callback = proc do |event|
283
- if event[:type] == :node_result
284
- event = event.merge(result: ApplyResult.from_task_result(event[:result]))
212
+ if future.rejected?
213
+ batch.map do |batch_target|
214
+ # If an unhandled exception occurred, wrap it in an ApplyError
215
+ error = if future.reason.is_a?(Bolt::ApplyError)
216
+ future.reason
217
+ else
218
+ Bolt::ApplyError.new(batch_target, future.reason.message)
219
+ end
220
+ result = Bolt::ApplyResult.new(batch_target, error: error.to_h)
221
+ @executor.publish_event(type: :node_result, result: result)
222
+ result
285
223
  end
286
- @executor.publish_event(event)
287
- end
288
- # Respect the run_as default set on the executor
289
- options[:run_as] = @executor.run_as if @executor.run_as && !options.key?(:run_as)
224
+ else
225
+ arguments = {
226
+ 'catalog' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(catalog),
227
+ 'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins),
228
+ 'apply_settings' => @apply_settings,
229
+ '_task' => catalog_apply_task.name,
230
+ '_noop' => options[:noop]
231
+ }
232
+
233
+ callback = proc do |event|
234
+ if event[:type] == :node_result
235
+ event = event.merge(result: ApplyResult.from_task_result(event[:result]))
236
+ end
237
+ @executor.publish_event(event)
238
+ end
239
+ # Respect the run_as default set on the executor
240
+ options[:run_as] = @executor.run_as if @executor.run_as && !options.key?(:run_as)
290
241
 
291
- results = transport.batch_task(batch, catalog_apply_task, arguments, options, &callback)
292
- Array(results).map { |result| ApplyResult.from_task_result(result) }
242
+ results = transport.batch_task(batch, catalog_apply_task, arguments, options, &callback)
243
+ Array(results).map { |result| ApplyResult.from_task_result(result) }
244
+ end
293
245
  end
294
246
  end
295
247
  end