Skip to content

Commit 4e8ac6e

Browse files
committed
Rely on the generated CA certificate location when deploying the CA cert
Signed-off-by: Eric D. Helms <[email protected]>
1 parent fcaa4a3 commit 4e8ac6e

File tree

7 files changed

+41
-60
lines changed

7 files changed

+41
-60
lines changed

manifests/apache.pp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123

124124
if $deploy {
125125
include certs::config::deploy
126+
require certs::ca
126127

127128
certs::keypair { $apache_cert_name:
128129
source_dir => "${certs::ssl_build_dir}/${hostname}",
@@ -136,5 +137,21 @@
136137
cert_mode => '0440',
137138
require => $require_cert,
138139
}
140+
141+
file { $certs::katello_default_ca_cert:
142+
ensure => file,
143+
source => $certs::ca::default_ca_path,
144+
owner => 'root',
145+
group => 'root',
146+
mode => '0644',
147+
}
148+
149+
file { $certs::katello_server_ca_cert:
150+
ensure => file,
151+
source => $certs::ca::server_ca_path,
152+
owner => 'root',
153+
group => 'root',
154+
mode => '0644',
155+
}
139156
}
140157
}

manifests/ca.pp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
String $org_unit = $certs::org_unit,
1212
String $ca_expiration = $certs::ca_expiration,
1313
Boolean $generate = $certs::generate,
14-
Boolean $deploy = $certs::deploy,
1514
String $owner = $certs::user,
1615
String $group = $certs::group,
17-
Stdlib::Absolutepath $katello_server_ca_cert = $certs::katello_server_ca_cert,
1816
String $ca_key_password = $certs::ca_key_password,
1917
Stdlib::Absolutepath $ca_key_password_file = $certs::ca_key_password_file,
2018
) {
@@ -71,24 +69,4 @@
7169
}
7270
}
7371
}
74-
75-
if $deploy {
76-
include certs::config::deploy
77-
78-
file { $certs::katello_default_ca_cert:
79-
ensure => file,
80-
source => $default_ca_path,
81-
owner => 'root',
82-
group => 'root',
83-
mode => '0644',
84-
}
85-
86-
file { $katello_server_ca_cert:
87-
ensure => file,
88-
source => $server_ca_path,
89-
owner => $owner,
90-
group => $group,
91-
mode => '0644',
92-
}
93-
}
9472
}

manifests/foreman.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
String $org_unit = 'PUPPET',
1616
String $expiration = $certs::expiration,
1717
Stdlib::Absolutepath $ca_key_password_file = $certs::ca_key_password_file,
18-
Stdlib::Absolutepath $server_ca = $certs::katello_server_ca_cert,
18+
Optional[Stdlib::Absolutepath] $server_ca = undef,
1919
String $owner = 'root',
2020
String $group = 'foreman',
2121
) inherits certs {
@@ -41,6 +41,8 @@
4141
}
4242

4343
if $deploy {
44+
require certs::ca
45+
4446
certs::keypair { $client_cert_name:
4547
source_dir => "${certs::ssl_build_dir}/${hostname}",
4648
key_file => $client_key,

manifests/foreman_proxy.pp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
Stdlib::Absolutepath $foreman_ssl_key = '/etc/foreman-proxy/foreman_ssl_key.pem',
1919
Stdlib::Absolutepath $foreman_ssl_ca_cert = '/etc/foreman-proxy/foreman_ssl_ca.pem',
2020
Stdlib::Absolutepath $pki_dir = $certs::pki_dir,
21-
Stdlib::Absolutepath $server_ca_cert = $certs::katello_server_ca_cert,
21+
Stdlib::Absolutepath $server_ca_cert = $certs::ca::server_ca_path,
2222
Optional[Stdlib::Absolutepath] $server_cert = $certs::server_cert,
2323
Optional[Stdlib::Absolutepath] $server_key = $certs::server_key,
2424
Optional[Stdlib::Absolutepath] $server_cert_req = $certs::server_cert_req,
2525
String[2,2] $country = $certs::country,
2626
String $state = $certs::state,
2727
String $city = $certs::city,
2828
String $expiration = $certs::expiration,
29-
Stdlib::Absolutepath $default_ca_cert = $certs::katello_default_ca_cert,
29+
Stdlib::Absolutepath $default_ca_cert = $certs::ca::default_ca_path,
3030
Stdlib::Absolutepath $ca_key_password_file = $certs::ca_key_password_file,
3131
String $group = 'foreman-proxy',
3232
String $owner = 'root',
@@ -108,6 +108,7 @@
108108

109109
if $deploy {
110110
include certs::config::deploy
111+
require certs::ca
111112

112113
certs::keypair { $proxy_cert_name:
113114
source_dir => "${certs::ssl_build_dir}/${hostname}",
@@ -123,12 +124,11 @@
123124
}
124125

125126
file { $proxy_ca_cert:
126-
ensure => file,
127-
source => $default_ca_cert,
128-
owner => $owner,
129-
group => $group,
130-
mode => '0440',
131-
require => File[$default_ca_cert],
127+
ensure => file,
128+
source => $default_ca_cert,
129+
owner => $owner,
130+
group => $group,
131+
mode => '0440',
132132
}
133133

134134
certs::keypair { $foreman_proxy_client_cert_name:
@@ -145,12 +145,11 @@
145145
}
146146

147147
file { $foreman_ssl_ca_cert:
148-
ensure => file,
149-
source => $server_ca_cert,
150-
owner => $owner,
151-
group => $group,
152-
mode => '0440',
153-
require => File[$server_ca_cert],
148+
ensure => file,
149+
source => $server_ca_cert,
150+
owner => $owner,
151+
group => $group,
152+
mode => '0440',
154153
}
155154

156155
cert_key_bundle { $foreman_proxy_ssl_client_bundle:

manifests/iop_advisor_engine.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@
3737
}
3838

3939
if $deploy {
40+
require certs::ca
41+
4042
$cert_directory = '/etc/iop-advisor-engine'
4143

4244
$server_cert = "${cert_directory}/server.cert"
4345
$server_key = "${cert_directory}/server.key"
44-
$server_ca_cert = $certs::katello_server_ca_cert
46+
$server_ca_cert = $certs::ca::server_ca_path
4547

4648
$client_cert = $certs::foreman_proxy::foreman_ssl_cert
4749
$client_key = $certs::foreman_proxy::foreman_ssl_key

manifests/puppet.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
String $city = $certs::city,
1414
String $expiration = $certs::expiration,
1515
Stdlib::Absolutepath $ca_key_password_file = $certs::ca_key_password_file,
16-
Stdlib::Absolutepath $server_ca = $certs::katello_server_ca_cert,
16+
Stdlib::Absolutepath $server_ca = $certs::ca::server_ca_path,
1717
Stdlib::Absolutepath $pki_dir = $certs::pki_dir,
1818
String $owner = 'root',
1919
String $group = 'puppet',
@@ -40,6 +40,7 @@
4040

4141
if $deploy {
4242
include certs::config::deploy
43+
require certs::ca
4344

4445
file { "${pki_dir}/puppet":
4546
ensure => directory,

spec/acceptance/certs_spec.rb

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe 'certs' do
44
before(:all) do
5-
on default, 'rm -rf /root/ssl-build'
5+
on default, 'rm -rf /root/ssl-build /etc/pki/katello'
66
end
77

88
context 'with default params' do
@@ -42,22 +42,8 @@
4242
it { should be_encrypted }
4343
end
4444

45-
describe x509_certificate('/etc/pki/katello/certs/katello-default-ca.crt') do
46-
it { should be_certificate }
47-
it { should be_valid }
48-
it { should have_purpose 'SSL server CA' }
49-
its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) }
50-
its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) }
51-
its(:keylength) { should be >= 4096 }
52-
end
53-
54-
describe x509_certificate('/etc/pki/katello/certs/katello-server-ca.crt') do
55-
it { should be_certificate }
56-
it { should be_valid }
57-
it { should have_purpose 'SSL server CA' }
58-
its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) }
59-
its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fact('fqdn')}/) }
60-
its(:keylength) { should be >= 4096 }
45+
describe file('/etc/pki/katello/certs/katello-default-ca.crt') do
46+
it { should_not exist }
6147
end
6248

6349
describe file('/etc/pki/katello/private/katello-default-ca.key') do
@@ -75,10 +61,6 @@
7561
describe file('/root/ssl-build/katello-default-ca.pwd') do
7662
it { should exist }
7763
end
78-
79-
describe file('/etc/pki/katello/private/katello-default-ca.pwd') do
80-
it { should_not exist }
81-
end
8264
end
8365

8466
context 'with deploy false' do

0 commit comments

Comments
 (0)