Skip to content

Commit e72630a

Browse files
Allow overriding hostprivkey (#962)
Update manifests/init.pp Co-authored-by: Tim Meusel <[email protected]>
1 parent 771fcee commit e72630a

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

manifests/config.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
$use_srv_records = $puppet::use_srv_records,
1919
$additional_settings = $puppet::additional_settings,
2020
$client_certname = $puppet::client_certname,
21+
$hostprivkey = $puppet::hostprivkey,
2122
# lint:endignore
2223
) {
2324
puppet::config::main {
@@ -26,7 +27,7 @@
2627
'rundir': value => $puppet::rundir;
2728
'ssldir': value => $puppet::ssldir;
2829
'privatekeydir': value => '$ssldir/private_keys { group = service }';
29-
'hostprivkey': value => '$privatekeydir/$certname.pem { mode = 640 }';
30+
'hostprivkey': value => $hostprivkey;
3031
'show_diff': value => $puppet::show_diff;
3132
'codedir': value => $puppet::codedir;
3233
}

manifests/init.pp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
# $certificate_revocation:: Whether certificate revocation checking should be
9797
# enabled, and what level of checking should be performed
9898
#
99+
# $hostprivkey:: Override the hostprivkey setting in puppet.conf
100+
#
99101
# $dns_alt_names:: Use additional DNS names when generating a
100102
# certificate. Defaults to an empty Array.
101103
#
@@ -629,6 +631,7 @@
629631
Optional[Variant[Boolean, Enum['chain', 'leaf']]] $certificate_revocation = $puppet::params::certificate_revocation,
630632
Optional[String] $prerun_command = $puppet::params::prerun_command,
631633
Optional[String] $postrun_command = $puppet::params::postrun_command,
634+
String[1] $hostprivkey = $puppet::params::hostprivkey,
632635
Array[String] $dns_alt_names = $puppet::params::dns_alt_names,
633636
Boolean $use_srv_records = $puppet::params::use_srv_records,
634637
Optional[String] $srv_domain = $puppet::params::srv_domain,

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
$prerun_command = undef
3232
$postrun_command = undef
3333
$server_compile_mode = undef
34+
$hostprivkey = '$privatekeydir/$certname.pem { mode = 640 }'
3435
$dns_alt_names = []
3536
$use_srv_records = false
3637
$agent_default_schedules = false

spec/classes/puppet_config_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@
163163
end
164164
end
165165

166+
describe 'with custom hostprivkey set' do
167+
let :params do
168+
super().merge(hostprivkey: '$privatekeydir/$certname.pem { mode = 660 }')
169+
end
170+
171+
it { is_expected.to contain_puppet__config__main('hostprivkey').with_value('$privatekeydir/$certname.pem { mode = 660 }') }
172+
end
173+
166174
describe 'with additional settings' do
167175
let :params do
168176
super().merge(additional_settings: { disable_warnings: 'deprecations' })

0 commit comments

Comments
 (0)