From a132b682b3cae9e9d2d3d94fd285bc1a7d73fff1 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Wed, 7 Dec 2022 22:50:28 +0100 Subject: [PATCH] Fixes #35870 - Ensure mod_expires is loaded In case only minimal Apache modules are loaded then mod_expires may not be present. The result is that assets are sent without headers that allow browsers to cache it. --- manifests/config/apache.pp | 6 +++++- spec/classes/foreman_config_apache_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/manifests/config/apache.pp b/manifests/config/apache.pp index 9981bec85..c4ed97c95 100644 --- a/manifests/config/apache.pp +++ b/manifests/config/apache.pp @@ -154,8 +154,12 @@ if $suburi { $custom_fragment = undef } else { - # mod_env is required by configuration in _assets.conf.erb + # mod_env and mod_expires are required by configuration in _assets.conf.erb include apache::mod::env + # apache::mod::expires pulls in a config file we don't want, like apache::default_mods + # It uses ensure_resource to be compatible with both $apache::default_mods set to true and false + include apache + ensure_resource('apache::mod', 'expires') $custom_fragment = file('foreman/_assets.conf.erb') } diff --git a/spec/classes/foreman_config_apache_spec.rb b/spec/classes/foreman_config_apache_spec.rb index b32793cfc..5b8f73f16 100644 --- a/spec/classes/foreman_config_apache_spec.rb +++ b/spec/classes/foreman_config_apache_spec.rb @@ -18,6 +18,8 @@ it { should compile.with_all_deps } it 'should include apache with modules' do + should contain_class('apache::mod::env') + should contain_apache__mod('expires') should contain_class('apache::mod::proxy') should contain_class('apache::mod::proxy_http') should contain_class('apache::mod::proxy_wstunnel') @@ -79,6 +81,26 @@ should_not contain_apache__vhost('foreman-ssl') end + describe 'with $apache::default_mods set to false' do + let(:pre_condition) do + <<~PUPPET + class { 'apache': + default_mods => false, + } + PUPPET + end + + it { should compile.with_all_deps } + it 'includes apache modules' do + should contain_class('apache::mod::env') + should contain_apache__mod('expires') + should contain_class('apache::mod::proxy') + should contain_class('apache::mod::proxy_http') + should contain_class('apache::mod::proxy_wstunnel') + should contain_class('apache::mod::rewrite') + end + end + describe 'with keycloak' do let(:params) { super().merge(keycloak: true) }