Skip to content

Commit 41453c5

Browse files
committed
Allow overriding passwords generated by extlib
Update suggestions
1 parent 39713ae commit 41453c5

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

manifests/candlepin.pp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
Stdlib::Absolutepath $ca_cert = $certs::candlepin_ca_cert,
99
Stdlib::Absolutepath $ca_key = $certs::candlepin_ca_key,
1010
Stdlib::Absolutepath $pki_dir = $certs::pki_dir,
11+
Optional[String] $keystore_password = undef,
1112
Stdlib::Absolutepath $keystore = $certs::candlepin_keystore,
1213
String $keystore_password_file = 'keystore_password-file',
14+
Optional[String] $truststore_password = undef,
1315
Stdlib::Absolutepath $truststore = $certs::candlepin_truststore,
1416
String $truststore_password_file = 'truststore_password-file',
1517
String[2,2] $country = $certs::country,
@@ -67,8 +69,20 @@
6769
build_dir => $certs::ssl_build_dir,
6870
}
6971

70-
$keystore_password = extlib::cache_data('foreman_cache_data', $keystore_password_file, extlib::random_password(32))
71-
$truststore_password = extlib::cache_data('foreman_cache_data', $truststore_password_file, extlib::random_password(32))
72+
# Generate and cache the password on the master once
73+
# In multi-puppetmaster setups, the user should specify their own
74+
if $keystore_password {
75+
$final_keystore_password = $keystore_password
76+
} else {
77+
$final_keystore_password = extlib::cache_data('foreman_cache_data', $keystore_password_file, extlib::random_password(32))
78+
}
79+
80+
if $truststore_password {
81+
$final_truststore_password = $truststore_password
82+
} else {
83+
$final_truststore_password = extlib::cache_data('foreman_cache_data', $truststore_password_file, extlib::random_password(32))
84+
}
85+
7286
$keystore_password_path = "${pki_dir}/${keystore_password_file}"
7387
$truststore_password_path = "${pki_dir}/${truststore_password_file}"
7488
$client_key = $certs::foreman::client_key
@@ -109,7 +123,7 @@
109123

110124
file { $keystore_password_path:
111125
ensure => file,
112-
content => $keystore_password,
126+
content => $final_keystore_password,
113127
owner => 'root',
114128
group => $group,
115129
mode => '0440',
@@ -134,7 +148,7 @@
134148

135149
file { $truststore_password_path:
136150
ensure => file,
137-
content => $truststore_password,
151+
content => $final_truststore_password,
138152
owner => 'root',
139153
group => $group,
140154
mode => '0440',

manifests/init.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
# $deploy:: Deploy the certs on the configured system. False means
4040
# we want to apply it to a different system
4141
#
42+
# $ca_key_password:: Optional string to use for the CA key password
43+
#
4244
# $ca_common_name:: Common name for the generated CA certificate
4345
#
4446
# $country:: Country attribute for managed certificates
@@ -73,6 +75,7 @@
7375
Boolean $generate = true,
7476
Boolean $regenerate = false,
7577
Boolean $deploy = true,
78+
String[10] $ca_key_password = $certs::params::ca_key_password,
7679
String $ca_common_name = $certs::params::ca_common_name,
7780
String[2,2] $country = 'US',
7881
String $state = 'North Carolina',
@@ -103,7 +106,6 @@
103106
$ca_key = "${pki_dir}/private/${default_ca_name}.key"
104107
$ca_cert = "${pki_dir}/certs/${default_ca_name}.crt"
105108
$ca_cert_stripped = "${pki_dir}/certs/${default_ca_name}-stripped.crt"
106-
$ca_key_password = extlib::cache_data('foreman_cache_data', 'ca_key_password', extlib::random_password(24))
107109
$ca_key_password_file = "${ssl_build_dir}/${default_ca_name}.pwd"
108110

109111
$katello_server_ca_cert = "${pki_dir}/certs/${server_ca_name}.crt"

manifests/params.pp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@
1919
$candlepin_ca_key = "${candlepin_certs_dir}/candlepin-ca.key"
2020

2121
$pulp_pki_dir = '/etc/pki/pulp'
22+
23+
# Generate and cache the password on the master once
24+
# In multi-puppetmaster setups, the user should specify their own
25+
$ca_key_password = extlib::cache_data('foreman_cache_data', 'ca_key_password', extlib::random_password(24))
2226
}

0 commit comments

Comments
 (0)