Skip to content

Commit 17ae497

Browse files
committed
Add class to configure generating certificates
Signed-off-by: Eric D. Helms <[email protected]>
1 parent b7c5b1a commit 17ae497

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed

manifests/generate.pp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Handles generating certificates
2+
#
3+
# === Parameters:
4+
#
5+
# $apache:: Generates certificates needed by Apache
6+
#
7+
# $foreman:: Generates certificates needed by Foreman
8+
#
9+
# $candlepin:: Generates certificates needed by Candlepin
10+
#
11+
# $foreman_proxy:: Generates certificates needed by Foreman Proxy
12+
#
13+
# $puppet:: Generates certificates needed by Puppet
14+
#
15+
class certs::generate (
16+
Boolean $apache = false,
17+
Boolean $foreman = false,
18+
Boolean $candlepin = false,
19+
Boolean $foreman_proxy = false,
20+
Boolean $puppet = false,
21+
) {
22+
class { 'certs::apache':
23+
generate => $apache,
24+
deploy => false,
25+
}
26+
27+
class { 'certs::foreman':
28+
generate => $foreman,
29+
deploy => false,
30+
}
31+
32+
class { 'certs::candlepin':
33+
generate => $candlepin,
34+
deploy => false,
35+
hostname => 'localhost',
36+
}
37+
38+
class { 'certs::foreman_proxy':
39+
generate => $foreman_proxy,
40+
deploy => false,
41+
}
42+
43+
class { 'certs::puppet':
44+
generate => $puppet,
45+
deploy => false,
46+
}
47+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'certs::foreman_proxy_content' do
4+
fqdn = fact('fqdn')
5+
6+
before(:all) do
7+
on default, 'rm -rf /root/ssl-build /etc/pki/katello'
8+
end
9+
10+
context 'with foreman true' do
11+
before(:context) do
12+
manifest = <<~PUPPET
13+
class { 'certs::generate':
14+
foreman => true,
15+
}
16+
PUPPET
17+
18+
apply_manifest(manifest, catch_failures: true)
19+
end
20+
21+
describe x509_certificate("/root/ssl-build/#{fqdn}/#{fqdn}-foreman-client.crt") do
22+
it { should be_certificate }
23+
it { should be_valid }
24+
it { should have_purpose 'client' }
25+
its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fqdn}/) }
26+
its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, O = FOREMAN, OU = PUPPET, CN = #{fqdn}/) }
27+
its(:keylength) { should be >= 4096 }
28+
end
29+
30+
describe x509_private_key("/root/ssl-build/#{fqdn}/#{fqdn}-foreman-client.key") do
31+
it { should_not be_encrypted }
32+
it { should be_valid }
33+
it { should have_matching_certificate("/root/ssl-build/#{fqdn}/#{fqdn}-foreman-client.crt") }
34+
end
35+
end
36+
end
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
require 'spec_helper'
2+
3+
describe 'certs::generate' do
4+
on_supported_os.each do |os, os_facts|
5+
context "on #{os}" do
6+
let :facts do
7+
os_facts
8+
end
9+
10+
describe 'with default parameters' do
11+
it { should compile.with_all_deps }
12+
end
13+
14+
describe 'with apache true' do
15+
let :params do
16+
{ apache: true }
17+
end
18+
19+
it { should compile.with_all_deps }
20+
21+
it do
22+
is_expected.to contain_class('certs::apache')
23+
end
24+
end
25+
26+
describe 'with foreman true' do
27+
let :params do
28+
{ foreman: true }
29+
end
30+
31+
it { should compile.with_all_deps }
32+
33+
it do
34+
is_expected.to contain_class('certs::foreman')
35+
end
36+
end
37+
38+
describe 'with candlepin true' do
39+
let :params do
40+
{ candlepin: true }
41+
end
42+
43+
it { should compile.with_all_deps }
44+
45+
it do
46+
is_expected.to contain_class('certs::candlepin')
47+
end
48+
end
49+
50+
describe 'with foreman_proxy true' do
51+
let :params do
52+
{ foreman_proxy: true }
53+
end
54+
55+
it { should compile.with_all_deps }
56+
57+
it do
58+
is_expected.to contain_class('certs::foreman_proxy')
59+
end
60+
end
61+
62+
describe 'with puppet true' do
63+
let :params do
64+
{ puppet: true }
65+
end
66+
67+
it { should compile.with_all_deps }
68+
69+
it do
70+
is_expected.to contain_class('certs::puppet')
71+
end
72+
end
73+
end
74+
end
75+
end

0 commit comments

Comments
 (0)