From cf9c338fdbf865675fdf4755edd84cbf3315e715 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 15 Nov 2024 08:21:15 +0100 Subject: [PATCH] add dedicated website profile for web + downloads --- puppet/data/common.yaml | 1 + puppet/manifests/site.pp | 5 ++++ puppet/modules/profiles/manifests/website.pp | 25 ++++++++++++++++++++ puppet/spec/classes/profiles_website_spec.rb | 17 +++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 puppet/modules/profiles/manifests/website.pp create mode 100644 puppet/spec/classes/profiles_website_spec.rb diff --git a/puppet/data/common.yaml b/puppet/data/common.yaml index 554bf8abd..ab121f1b6 100644 --- a/puppet/data/common.yaml +++ b/puppet/data/common.yaml @@ -1,6 +1,7 @@ --- stable_release: '3.12' profiles::web::stable: '%{alias("stable_release")}' +profiles::website::stable: '%{alias("stable_release")}' profiles::repo::deb::stable: '%{alias("stable_release")}' profiles::repo::rpm::stable_foreman: '%{alias("stable_release")}' diff --git a/puppet/manifests/site.pp b/puppet/manifests/site.pp index b43befa30..8d1d6a336 100644 --- a/puppet/manifests/site.pp +++ b/puppet/manifests/site.pp @@ -51,3 +51,8 @@ include profiles::base include profiles::repo::rpm } + +node /^website\d+\.[a-z]+\.theforeman\.org$/ { + include profiles::base + include profiles::website +} diff --git a/puppet/modules/profiles/manifests/website.pp b/puppet/modules/profiles/manifests/website.pp new file mode 100644 index 000000000..785e3d841 --- /dev/null +++ b/puppet/modules/profiles/manifests/website.pp @@ -0,0 +1,25 @@ +# @summary A profile for the machines hosting the website and downloads +# +# @param stable +# Latest release that users expect +# +# @param https +# Whether to enable HTTPS. This is typically wanted but can only be enabled +# in a 2 pass setup. First Apache needs to run for Letsencrypt to function. +# Then Letsencrypt can be enabled. Also useful to turn off in test setups. +class profiles::website ( + String[1] $stable, + Boolean $https = true, +) { + class { 'web': + https => $https, + } + contain web + + contain web::vhost::downloads + + class { 'web::vhost::web': + stable => $stable, + } + contain web::vhost::web +} diff --git a/puppet/spec/classes/profiles_website_spec.rb b/puppet/spec/classes/profiles_website_spec.rb new file mode 100644 index 000000000..0e7439255 --- /dev/null +++ b/puppet/spec/classes/profiles_website_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'profiles::website' do + on_supported_os.each do |os, os_facts| + context "on #{os}" do + let(:facts) { os_facts } + + it { is_expected.to compile.with_all_deps } + + context 'without https' do + let(:params) { { https: false } } + + it { is_expected.to compile.with_all_deps } + end + end + end +end