From d3046e570be7099cba1e62d7260ad28761392ee3 Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Thu, 14 Dec 2023 13:25:13 -0600 Subject: [PATCH] support using the target agent puppet config modules like puppetlabs-puppetdb which make use of Puppet.runtime[:http] require the agent ssl certificate and key. this change supports an optional flag which simply skips the confdir setting override when initializing the Puppet object. --- lib/bolt/applicator.rb | 5 +++-- libexec/apply_catalog.rb | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/bolt/applicator.rb b/lib/bolt/applicator.rb index eaf4d0da0e..f832fc6843 100644 --- a/lib/bolt/applicator.rb +++ b/lib/bolt/applicator.rb @@ -264,7 +264,7 @@ def apply_ast(raw_ast, targets, options, plan_vars = {}) result_promises = targets.zip(futures).flat_map do |target, future| @executor.queue_execute([target]) do |transport, batch| - @executor.with_node_logging("Applying manifest block", batch) do + @executor.with_node_logging("Applying manifest block%s" % (" (with agent confdir)" if options[:agent]), batch) do catalog = future.value if future.rejected? batch.map do |batch_target| @@ -285,7 +285,8 @@ def apply_ast(raw_ast, targets, options, plan_vars = {}) 'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins), 'apply_settings' => @apply_settings, '_task' => catalog_apply_task.name, - '_noop' => options[:noop] + '_noop' => options[:noop], + '_agent' => options[:agent] } callback = proc do |event| diff --git a/libexec/apply_catalog.rb b/libexec/apply_catalog.rb index ccf6d62232..7542bae0b5 100755 --- a/libexec/apply_catalog.rb +++ b/libexec/apply_catalog.rb @@ -17,9 +17,9 @@ puppet_root = Dir.mktmpdir moduledir = File.join(puppet_root, 'modules') Dir.mkdir(moduledir) -cli = (Puppet::Settings::REQUIRED_APP_SETTINGS + [:rundir]).flat_map do |setting| - ["--#{setting}", File.join(puppet_root, setting.to_s.chomp('dir'))] -end +cli = (Puppet::Settings::REQUIRED_APP_SETTINGS + [:rundir]).filter_map do |setting| + ["--#{setting}", File.join(puppet_root, setting.to_s.chomp('dir'))] unless (args['_agent'] && setting == :confdir) +end.flatten cli << '--modulepath' << moduledir Puppet.initialize_settings(cli)