Skip to content

Commit

Permalink
support using the target puppet config
Browse files Browse the repository at this point in the history
!feature !experimental

* **add new option to apply-settings** ([#3255](#3255))

A new enum option 'confdir' supports overriding the default behavior
of using a bolt temporary confdir for each Puppet apply. This feature is
currently considered experimental.
  • Loading branch information
h0tw1r3 committed Dec 15, 2023
1 parent cdc7b56 commit 8a062b9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/bolt/config/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ module Options
"plan function or the `bolt apply` command.",
type: Hash,
properties: {
"confdir" => {
description: "This feature is experimental. Use the bolt created temporary path "\
"or the Puppet default confdir on the target.",
type: String,
enum: %w[bolt target],
_example: "target",
_default: "bolt"
},
"evaltrace" => {
description: "Whether each resource should log when it is being evaluated. This allows "\
"you to interactively see exactly what is being done.",
Expand Down
13 changes: 12 additions & 1 deletion libexec/apply_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
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'))]
if setting == :confdir && args['apply_settings']['confdir'] == 'target'
# skip isolating confdir and override basemodulepath
# as we never want to load agent modules
['--basemodulepath', Puppet.default_basemodulepath]
else
["--#{setting}", File.join(puppet_root, setting.to_s.chomp('dir'))]
end
end
cli << '--modulepath' << moduledir
Puppet.initialize_settings(cli)
Expand All @@ -28,6 +34,11 @@

# Make sure to apply the catalog
Puppet[:noop] = args['_noop'] || false

# delete because its not an actual path
# and can't be changed after initialization
delete(args['apply_settings']['confdir'])

args['apply_settings'].each do |setting, value|
Puppet[setting.to_sym] = value
end
Expand Down
8 changes: 8 additions & 0 deletions schemas/bolt-project.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@
"description": "A map of Puppet settings to use when applying Puppet code using the `apply` plan function or the `bolt apply` command.",
"type": "object",
"properties": {
"confdir": {
"description": "This feature is experimental. Use the bolt created temporary path or the Puppet default confdir on the target.",
"type": "string",
"enum": [
"bolt",
"target"
]
},
"evaltrace": {
"description": "Whether each resource should log when it is being evaluated. This allows you to interactively see exactly what is being done.",
"type": "boolean"
Expand Down

0 comments on commit 8a062b9

Please sign in to comment.