bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb in bolt-1.49.0 vs bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb in bolt-2.0.0
- old
+ new
@@ -1,18 +1,18 @@
# frozen_string_literal: true
require 'bolt/task'
-# Installs the puppet-agent package on targets if needed, then collects facts,
+# Installs the `puppet-agent` package on targets if needed, then collects facts,
# including any custom facts found in Bolt's modulepath. The package is
# installed using either the configured plugin or the `task` plugin with the
# `puppet_agent::install` task.
#
-# Agent installation will be skipped if the target includes the 'puppet-agent' feature, either as a
+# Agent installation will be skipped if the target includes the `puppet-agent` feature, either as a
# property of its transport (PCP) or by explicitly setting it as a feature in Bolt's inventory.
#
-# **NOTE:** Not available in apply block
+# > **Note:** Not available in apply block
Puppet::Functions.create_function(:apply_prep) do
# @param targets A pattern or array of patterns identifying a set of targets.
# @example Prepare targets by name.
# apply_prep('target1,target2')
dispatch :apply_prep do
@@ -81,18 +81,16 @@
# lazy-load expensive gem code
require 'concurrent'
pool = Concurrent::ThreadPoolExecutor.new
hooks = need_install_targets.map do |t|
- begin
- opts = t.plugin_hooks&.fetch('puppet_library').dup
- plugin_name = opts.delete('plugin')
- hook = inventory.plugins.get_hook(plugin_name, :puppet_library)
- { 'target' => t,
- 'hook_proc' => hook.call(opts, t, self) }
- rescue StandardError => e
- Bolt::Result.from_exception(t, e)
- end
+ opts = t.plugin_hooks&.fetch('puppet_library').dup
+ plugin_name = opts.delete('plugin')
+ hook = inventory.plugins.get_hook(plugin_name, :puppet_library)
+ { 'target' => t,
+ 'hook_proc' => hook.call(opts, t, self) }
+ rescue StandardError => e
+ Bolt::Result.from_exception(t, e)
end
hook_errors, ok_hooks = hooks.partition { |h| h.is_a?(Bolt::Result) }
futures = ok_hooks.map do |hash|