Skip to content

Commit

Permalink
remove plugin tarbal from the target loop
Browse files Browse the repository at this point in the history
  • Loading branch information
hajee committed Jul 5, 2020
1 parent b5f8818 commit b7f8852
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions bolt-modules/boltlib/lib/puppet/functions/apply_prep.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ def apply_prep(target_spec, options = {})
Puppet.debug("Syncing only required modules: #{@required_modules.join(',')}.")
end

# Gather facts, including custom facts
plugins = applicator.build_plugin_tarball do |mod|
next unless @required_modules.nil? || @required_modules.include?(mod.name)
search_dirs = []
search_dirs << mod.plugins if mod.plugins?
search_dirs << mod.pluginfacts if mod.pluginfacts?
search_dirs
end

executor.log_action('install puppet and gather facts', targets) do
executor.without_default_logging do
# Skip targets that include the puppet-agent feature, as we know an agent will be available.
Expand Down Expand Up @@ -119,15 +128,6 @@ def apply_prep(target_spec, options = {})
need_install_targets.each { |target| set_agent_feature(target) }
end

# Gather facts, including custom facts
plugins = applicator.build_plugin_tarball do |mod|
next unless @required_modules.nil? || @required_modules.include?(mod.name)
search_dirs = []
search_dirs << mod.plugins if mod.plugins?
search_dirs << mod.pluginfacts if mod.pluginfacts?
search_dirs
end

task = applicator.custom_facts_task
arguments = { 'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins) }
results = executor.run_task(targets, task, arguments)
Expand Down
34 changes: 17 additions & 17 deletions lib/bolt/applicator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ def apply_ast(raw_ast, targets, options, plan_vars = {})
@logger.debug("Syncing only required modules: #{@required_modules.join(',')}.")
end

@plugin_tarball = Concurrent::Delay.new do
build_plugin_tarball do |mod|
next unless @required_modules.nil? || @required_modules.include?(mod.name)
search_dirs = []
search_dirs << mod.plugins if mod.plugins?
search_dirs << mod.pluginfacts if mod.pluginfacts?
search_dirs << mod.files if mod.files?
type_files = "#{mod.path}/types"
search_dirs << type_files if File.exist?(type_files)
search_dirs
end
end

r = @executor.log_action(description, targets) do
futures = targets.map do |target|
Concurrent::Future.execute(executor: @pool) do
Expand Down Expand Up @@ -227,22 +240,9 @@ def apply_ast(raw_ast, targets, options, plan_vars = {})
end
else

plugin_tarball = Concurrent::Delay.new do
build_plugin_tarball do |mod|
next unless @required_modules.nil? || @required_modules.include?(mod.name)
search_dirs = []
search_dirs << mod.plugins if mod.plugins?
search_dirs << mod.pluginfacts if mod.pluginfacts?
search_dirs << mod.files if mod.files?
type_files = "#{mod.path}/types"
search_dirs << type_files if File.exist?(type_files)
search_dirs
end
end

arguments = {
'catalog' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(catalog),
'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins(plugin_tarball)),
'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins),
'apply_settings' => @apply_settings,
'_task' => catalog_apply_task.name,
'_noop' => options[:noop]
Expand Down Expand Up @@ -277,9 +277,9 @@ def apply_ast(raw_ast, targets, options, plan_vars = {})
r
end

def plugins(plugin_tarball)
plugin_tarball.value ||
raise(Bolt::Error.new("Failed to pack module plugins: #{plugin_tarball.reason}", 'bolt/plugin-error'))
def plugins
@plugin_tarball.value ||
raise(Bolt::Error.new("Failed to pack module plugins: #{@plugin_tarball.reason}", 'bolt/plugin-error'))
end

def build_plugin_tarball
Expand Down

0 comments on commit b7f8852

Please sign in to comment.