Skip to content

Commit e81090e

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 18c0279 commit e81090e

File tree

7 files changed

+46
-66
lines changed

7 files changed

+46
-66
lines changed

manifests/apache.pp

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

122122
if $deploy {
123123
include certs::config::deploy
124+
require certs::ca
124125

125126
certs::keypair { $apache_cert_name:
126127
source_dir => "${certs::ssl_build_dir}/${hostname}",
@@ -134,5 +135,21 @@
134135
cert_mode => '0440',
135136
require => $require_cert,
136137
}
138+
139+
file { $certs::katello_default_ca_cert:
140+
ensure => file,
141+
source => $certs::ca::default_ca_path,
142+
owner => 'root',
143+
group => 'root',
144+
mode => '0644',
145+
}
146+
147+
file { $certs::katello_server_ca_cert:
148+
ensure => file,
149+
source => $certs::ca::server_ca_path,
150+
owner => 'root',
151+
group => 'root',
152+
mode => '0644',
153+
}
137154
}
138155
}

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
Stdlib::Absolutepath $ca_cert = $certs::ca_cert,
1917
Stdlib::Absolutepath $ca_cert_stripped = $certs::ca_cert_stripped,
2018
String $ca_key_password = $certs::ca_key_password,
@@ -58,24 +56,4 @@
5856
ensure => absent,
5957
}
6058
}
61-
62-
if $deploy {
63-
include certs::config::deploy
64-
65-
file { $certs::katello_default_ca_cert:
66-
ensure => file,
67-
source => $default_ca_path,
68-
owner => 'root',
69-
group => 'root',
70-
mode => '0644',
71-
}
72-
73-
file { $katello_server_ca_cert:
74-
ensure => file,
75-
source => $server_ca_path,
76-
owner => $owner,
77-
group => $group,
78-
mode => '0644',
79-
}
80-
}
8159
}

manifests/foreman.pp

Lines changed: 8 additions & 7 deletions
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+
Stdlib::Absolutepath $server_ca = $certs::ca::server_ca_path,
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,
@@ -55,12 +57,11 @@
5557
}
5658

5759
file { $ssl_ca_cert:
58-
ensure => file,
59-
source => $server_ca,
60-
owner => 'root',
61-
group => $group,
62-
mode => '0440',
63-
require => File[$server_ca],
60+
ensure => file,
61+
source => $server_ca,
62+
owner => 'root',
63+
group => $group,
64+
mode => '0440',
6465
}
6566
}
6667
}

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
@@ -36,22 +36,8 @@
3636
it { should be_encrypted }
3737
end
3838

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

5743
describe file('/etc/pki/katello/private/katello-default-ca.key') do
@@ -69,10 +55,6 @@
6955
describe file('/root/ssl-build/katello-default-ca.pwd') do
7056
it { should exist }
7157
end
72-
73-
describe file('/etc/pki/katello/private/katello-default-ca.pwd') do
74-
it { should_not exist }
75-
end
7658
end
7759

7860
context 'with deploy false' do

0 commit comments

Comments
 (0)