Skip to content

Commit 86ee380

Browse files
committed
Only declare the CA if generate is requested
This avoids writing out a password file that isn't needed.
1 parent 4765129 commit 86ee380

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

manifests/ca.pp

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,29 @@
2424
$default_ca_path = "${certs::ssl_build_dir}/${default_ca_name}.crt"
2525
$server_ca_path = "${certs::ssl_build_dir}/${server_ca_name}.crt"
2626

27-
file { $ca_key_password_file:
28-
ensure => file,
29-
content => $ca_key_password,
30-
owner => 'root',
31-
group => 'root',
32-
mode => '0400',
33-
show_diff => false,
34-
} ~>
35-
ca { $default_ca_name:
36-
ensure => present,
37-
common_name => $ca_common_name,
38-
country => $country,
39-
state => $state,
40-
city => $city,
41-
org => $org,
42-
org_unit => $org_unit,
43-
expiration => $ca_expiration,
44-
generate => $generate,
45-
password_file => $ca_key_password_file,
46-
build_dir => $certs::ssl_build_dir,
47-
}
48-
4927
if $generate {
28+
file { $ca_key_password_file:
29+
ensure => file,
30+
content => $ca_key_password,
31+
owner => 'root',
32+
group => 'root',
33+
mode => '0400',
34+
show_diff => false,
35+
} ~>
36+
ca { $default_ca_name:
37+
ensure => present,
38+
common_name => $ca_common_name,
39+
country => $country,
40+
state => $state,
41+
city => $city,
42+
org => $org,
43+
org_unit => $org_unit,
44+
expiration => $ca_expiration,
45+
generate => $generate,
46+
password_file => $ca_key_password_file,
47+
build_dir => $certs::ssl_build_dir,
48+
}
49+
5050
file { $server_ca_path:
5151
ensure => file,
5252
source => pick($certs::server_ca_cert, $default_ca_path),
@@ -60,6 +60,10 @@
6060
target => $server_ca_path,
6161
require => File[$server_ca_path],
6262
}
63+
64+
$default_ca = Ca[$default_ca_name]
65+
} else {
66+
$default_ca = undef
6367
}
6468

6569
if $deploy {

manifests/init.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@
123123
Class['certs::config'] ->
124124
Class['certs::ca']
125125

126-
$default_ca = Ca[$default_ca_name]
126+
$default_ca = $certs::ca::default_ca
127127
}

0 commit comments

Comments
 (0)