Skip to content

Commit 1aedf72

Browse files
committed
Allow overriding hostprivkey
1 parent 5e728ee commit 1aedf72

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

manifests/config.pp

Lines changed: 10 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,6 @@
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 }';
3030
'show_diff': value => $puppet::show_diff;
3131
'codedir': value => $puppet::codedir;
3232
}
@@ -73,6 +73,15 @@
7373
'certname': value => $client_certname;
7474
}
7575
}
76+
if $hostprivkey {
77+
puppet::config::main {
78+
'hostprivkey': value => $hostprivkey;
79+
}
80+
} else {
81+
puppet::config::main {
82+
'hostprivkey': value => '$privatekeydir/$certname.pem { mode = 640 }';
83+
}
84+
}
7685

7786
$additional_settings.each |$key,$value| {
7887
puppet::config::main { $key: value => $value }

manifests/init.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@
626626
Optional[Variant[Boolean, Enum['chain', 'leaf']]] $certificate_revocation = $puppet::params::certificate_revocation,
627627
Optional[String] $prerun_command = $puppet::params::prerun_command,
628628
Optional[String] $postrun_command = $puppet::params::postrun_command,
629+
String $hostprivkey = $puppet::params::hostprivkey,
629630
Array[String] $dns_alt_names = $puppet::params::dns_alt_names,
630631
Boolean $use_srv_records = $puppet::params::use_srv_records,
631632
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 = undef
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: '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)