From 7103174df02eaf0f9a6b7e59224cdb54b41927fa Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Tue, 30 Apr 2024 11:07:00 -0400 Subject: [PATCH] Add class to configure generating certificates --- manifests/generate.pp | 41 ++++++++++++++++ spec/classes/certs_generate_spec.rb | 75 +++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 manifests/generate.pp create mode 100644 spec/classes/certs_generate_spec.rb diff --git a/manifests/generate.pp b/manifests/generate.pp new file mode 100644 index 00000000..746e10de --- /dev/null +++ b/manifests/generate.pp @@ -0,0 +1,41 @@ +# 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, +) { + if $certs::generate::apache { + include certs::apache + } + + if $certs::generate::foreman { + include certs::foreman + } + + if $certs::generate::candlepin { + include certs::candlepin + } + + if $certs::generate::foreman_proxy { + include certs::foreman_proxy + } + + if $certs::generate::puppet { + include certs::puppet + } +} diff --git a/spec/classes/certs_generate_spec.rb b/spec/classes/certs_generate_spec.rb new file mode 100644 index 00000000..885c6dd5 --- /dev/null +++ b/spec/classes/certs_generate_spec.rb @@ -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 :pre_condition do + "class {'certs::generate': 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 :pre_condition do + "class {'certs::generate': 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 :pre_condition do + "class {'certs::generate': 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 :pre_condition do + "class {'certs::generate': 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 :pre_condition do + "class {'certs::generate': puppet => true,}" + end + + it { should compile.with_all_deps } + + it do + is_expected.to contain_class('certs::puppet') + end + end + end + end +end