-
Notifications
You must be signed in to change notification settings - Fork 40
Add class to configure generating certificates #449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+176
−0
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Handles deploying certificates | ||
| # | ||
| # === Parameters: | ||
| # | ||
| # $foreman_proxy:: Deploy certificates needed by Foreman Proxy | ||
| # | ||
| class certs::deploy ( | ||
| Boolean $foreman_proxy = false, | ||
| ) { | ||
| class { 'certs::foreman_proxy': | ||
| generate => false, | ||
| deploy => $foreman_proxy, | ||
| } | ||
|
|
||
| if $foreman_proxy { | ||
| Class['certs::foreman_proxy'] ~> Service['foreman-proxy'] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Handles generating certificates | ||
| # | ||
| # === Parameters: | ||
| # | ||
| # $apache:: Generates certificates needed by Apache | ||
| # | ||
| # $foreman:: Generates certificates needed by Foreman | ||
| # | ||
| # $candlepin:: Generates certificates needed by Candlepin | ||
| # | ||
| # $foreman_proxy:: Generates certificates needed by Foreman Proxy | ||
| # | ||
| # $puppet:: Generates certificates needed by Puppet | ||
| # | ||
| class certs::generate ( | ||
| Boolean $apache = false, | ||
| Boolean $foreman = false, | ||
| Boolean $candlepin = false, | ||
| Boolean $foreman_proxy = false, | ||
| Boolean $puppet = false, | ||
| ) { | ||
| class { 'certs::apache': | ||
| generate => $apache, | ||
| deploy => false, | ||
| } | ||
|
|
||
| class { 'certs::foreman': | ||
| generate => $foreman, | ||
| deploy => false, | ||
| } | ||
|
|
||
| class { 'certs::candlepin': | ||
| generate => $candlepin, | ||
| deploy => false, | ||
| hostname => 'localhost', | ||
| } | ||
|
|
||
| class { 'certs::foreman_proxy': | ||
| generate => $foreman_proxy, | ||
| deploy => false, | ||
| } | ||
|
|
||
| class { 'certs::puppet': | ||
| generate => $puppet, | ||
| deploy => false, | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| require 'spec_helper_acceptance' | ||
|
|
||
| describe 'certs::foreman_proxy_content' do | ||
| fqdn = fact('fqdn') | ||
|
|
||
| before(:all) do | ||
| on default, 'rm -rf /root/ssl-build /etc/pki/katello' | ||
| end | ||
|
|
||
| context 'with foreman true' do | ||
| before(:context) do | ||
| manifest = <<~PUPPET | ||
| class { 'certs::generate': | ||
| foreman => true, | ||
| } | ||
| PUPPET | ||
|
|
||
| apply_manifest(manifest, catch_failures: true) | ||
| end | ||
|
|
||
| describe x509_certificate("/root/ssl-build/#{fqdn}/#{fqdn}-foreman-client.crt") do | ||
| it { should be_certificate } | ||
| it { should be_valid } | ||
| it { should have_purpose 'client' } | ||
| its(:issuer) { should match_without_whitespace(/C = US, ST = North Carolina, L = Raleigh, O = Katello, OU = SomeOrgUnit, CN = #{fqdn}/) } | ||
| its(:subject) { should match_without_whitespace(/C = US, ST = North Carolina, O = FOREMAN, OU = PUPPET, CN = #{fqdn}/) } | ||
| its(:keylength) { should be >= 4096 } | ||
| end | ||
|
|
||
| describe x509_private_key("/root/ssl-build/#{fqdn}/#{fqdn}-foreman-client.key") do | ||
| it { should_not be_encrypted } | ||
| it { should be_valid } | ||
| it { should have_matching_certificate("/root/ssl-build/#{fqdn}/#{fqdn}-foreman-client.crt") } | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| require 'spec_helper' | ||
|
|
||
| describe 'certs::generate' do | ||
| on_supported_os.each do |os, os_facts| | ||
| context "on #{os}" do | ||
| let :facts do | ||
| os_facts | ||
| end | ||
|
|
||
| describe 'with default parameters' do | ||
| it { should compile.with_all_deps } | ||
| end | ||
|
|
||
| describe 'with apache true' do | ||
| let :params do | ||
| { apache: true } | ||
| end | ||
|
|
||
| it { should compile.with_all_deps } | ||
|
|
||
| it do | ||
| is_expected.to contain_class('certs::apache') | ||
| end | ||
| end | ||
|
|
||
| describe 'with foreman true' do | ||
| let :params do | ||
| { foreman: true } | ||
| end | ||
|
|
||
| it { should compile.with_all_deps } | ||
|
|
||
| it do | ||
| is_expected.to contain_class('certs::foreman') | ||
| end | ||
| end | ||
|
|
||
| describe 'with candlepin true' do | ||
| let :params do | ||
| { candlepin: true } | ||
| end | ||
|
|
||
| it { should compile.with_all_deps } | ||
|
|
||
| it do | ||
| is_expected.to contain_class('certs::candlepin') | ||
| end | ||
| end | ||
|
|
||
| describe 'with foreman_proxy true' do | ||
| let :params do | ||
| { foreman_proxy: true } | ||
| end | ||
|
|
||
| it { should compile.with_all_deps } | ||
|
|
||
| it do | ||
| is_expected.to contain_class('certs::foreman_proxy') | ||
| end | ||
| end | ||
|
|
||
| describe 'with puppet true' do | ||
| let :params do | ||
| { puppet: true } | ||
| end | ||
|
|
||
| it { should compile.with_all_deps } | ||
|
|
||
| it do | ||
| is_expected.to contain_class('certs::puppet') | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.