From 94396557e1b1db703a0e404766114c9263148010 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Wed, 10 Aug 2022 13:41:55 +0200 Subject: [PATCH] Include apache::mod::filter in apache::mod::deflate This was already done in default mods, but this removes duplication and allows use without default mods. --- manifests/default_mods.pp | 9 --------- manifests/mod/deflate.pp | 9 +++++++++ spec/classes/mod/deflate_spec.rb | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifests/default_mods.pp b/manifests/default_mods.pp index f38af265cc..1b71b158e8 100644 --- a/manifests/default_mods.pp +++ b/manifests/default_mods.pp @@ -142,9 +142,6 @@ include apache::mod::auth_basic if versioncmp($apache_version, '2.4') >= 0 { - # filter is needed by mod_deflate - include apache::mod::filter - # authz_core is needed for 'Require' directive ::apache::mod { 'authz_core': id => 'authz_core_module', @@ -167,9 +164,6 @@ ::apache::mod { 'authz_core': id => 'authz_core_module', } - - # filter is needed by mod_deflate - include apache::mod::filter } } else { if versioncmp($apache_version, '2.4') >= 0 { @@ -177,9 +171,6 @@ ::apache::mod { 'authz_core': id => 'authz_core_module', } - - # filter is needed by mod_deflate - include apache::mod::filter } } } diff --git a/manifests/mod/deflate.pp b/manifests/mod/deflate.pp index c5a6aaac8a..d774999422 100644 --- a/manifests/mod/deflate.pp +++ b/manifests/mod/deflate.pp @@ -7,6 +7,9 @@ # @param notes # A Hash where the key represents the type and the value represents the note name. # +# @param apache_version +# The version of apache being run. +# # @see https://httpd.apache.org/docs/current/mod/mod_deflate.html for additional documentation. # class apache::mod::deflate ( @@ -22,8 +25,14 @@ 'Output' => 'outstream', 'Ratio' => 'ratio', } + Optional[String] $apache_version = undef, ) { include apache + + if versioncmp(pick($apache_version, $apache::apache_version), '2.4') >= 0 { + include apache::mod::filter + } + ::apache::mod { 'deflate': } file { 'deflate.conf': diff --git a/spec/classes/mod/deflate_spec.rb b/spec/classes/mod/deflate_spec.rb index 96ecaa0f82..d9f4056bcc 100644 --- a/spec/classes/mod/deflate_spec.rb +++ b/spec/classes/mod/deflate_spec.rb @@ -5,6 +5,7 @@ # This function is called inside the OS specific contexts def general_deflate_specs it { is_expected.to contain_apache__mod('deflate') } + it { is_expected.to contain_class('apache::mod::filter') } expected = "AddOutputFilterByType DEFLATE application/rss+xml\n"\ "AddOutputFilterByType DEFLATE application/x-javascript\n"\