Skip to content

Commit

Permalink
support using the target agent puppet config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
h0tw1r3 committed Dec 14, 2023
1 parent cdc7b56 commit d07d8ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions documentation/applying_manifest_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ The `apply` function supports the following options:
option is for transports that allow a user to run commands under a different
username.)
- `_agent => true` applies the manifest block with the targets default Puppet
confdir. Without this option, Bolt will use a temporary directory to prevent
Puppet from automatically reading any files from the targets local
configuration.
```puppet
# Preview installing docker as root on $targets.
apply($targets, _catch_errors => true, _noop => true, _run_as => root) {
Expand Down
6 changes: 4 additions & 2 deletions lib/bolt/applicator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ 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
message = format("Applying manifest block%s", (" (with agent confdir)" if options[:agent]))
@executor.with_node_logging(message, batch) do
catalog = future.value
if future.rejected?
batch.map do |batch_target|
Expand All @@ -285,7 +286,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|
Expand Down
5 changes: 4 additions & 1 deletion libexec/apply_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
puppet_root = Dir.mktmpdir
moduledir = File.join(puppet_root, 'modules')
Dir.mkdir(moduledir)
cli = (Puppet::Settings::REQUIRED_APP_SETTINGS + [:rundir]).flat_map do |setting|
settings = (Puppet::Settings::REQUIRED_APP_SETTINGS + [:rundir]).reject do |setting|
setting == :confdir && args['_agent']
end
cli = settings.flat_map do |setting|
["--#{setting}", File.join(puppet_root, setting.to_s.chomp('dir'))]
end
cli << '--modulepath' << moduledir
Expand Down

0 comments on commit d07d8ec

Please sign in to comment.