From 226d2d973bdd1f4e2b5f77ba01ed48da1e01c9d0 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 06:52:58 +0000 Subject: [PATCH 1/7] Ensure mod::dir is added when needed --- manifests/vhost.pp | 5 +++++ spec/defines/vhost_spec.rb | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 03c86938b..1036f9e28 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -2300,6 +2300,7 @@ } if $fallbackresource { + include apache::mod::dir $fall_back_res_params = { 'fallbackresource' => $fallbackresource, } @@ -2335,6 +2336,10 @@ include apache::mod::authz_groupfile } + if 'directoryindex' in $directory { + include apache::mod::dir + } + if 'gssapi' in $directory { include apache::mod::auth_gssapi } diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 355c20741..f94c93ffe 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -2188,6 +2188,23 @@ } end end + + context 'mod_dir is included when needed' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'directoryindex' => 'index.php', + }, + ] + + } + end + + it { is_expected.to compile } + it { is_expected.to contain_class('apache::mod::dir') } + end end end end From 77190eccb8da9ecf026a5b04476cb641921d370d Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:01:22 +0000 Subject: [PATCH 2/7] Ensure mod::expires is added when needed --- manifests/vhost.pp | 4 ++++ spec/defines/vhost_spec.rb | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 1036f9e28..230b36d81 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -2340,6 +2340,10 @@ include apache::mod::dir } + if 'expires_active' in $directory { + include apache::mod::expires + } + if 'gssapi' in $directory { include apache::mod::auth_gssapi } diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index f94c93ffe..2e1b774b1 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -2205,6 +2205,23 @@ it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::dir') } end + + context 'mod_expires is included when needed' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'expires_active' => 'On', + }, + ] + + } + end + + it { is_expected.to compile } + it { is_expected.to contain_class('apache::mod::expires') } + end end end end From 8d6fc683ab3b364779e50e484e8e0e5652749902 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:20:22 +0000 Subject: [PATCH 3/7] Ensure mod::dav is added when needed --- manifests/vhost.pp | 9 +++++++++ spec/defines/vhost_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 230b36d81..8f40af55d 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -2336,6 +2336,15 @@ include apache::mod::authz_groupfile } + if 'dav' in $directory { + include apache::mod::dav + if $directory['dav'] == 'On' { + include apache::mod::dav_fs + } elsif $directory['dav'] == 'svn' { + include apache::mod::dav_svn + } + } + if 'directoryindex' in $directory { include apache::mod::dir } diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 2e1b774b1..7bdbd8031 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -2222,6 +2222,42 @@ it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::expires') } end + + context 'mod_dav is included when on' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'dav' => 'On', + }, + ] + + } + end + + it { is_expected.to compile } + it { is_expected.to contain_class('apache::mod::dav') } + it { is_expected.to contain_class('apache::mod::dav_fs') } + end + + context 'mod_dav is included when set to svn' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'dav' => 'svn', + }, + ] + + } + end + + it { is_expected.to compile } + it { is_expected.to contain_class('apache::mod::dav') } + it { is_expected.to contain_class('apache::mod::dav_svn') } + end end end end From ad3cc5ed3d3ca8833401cef318620c31d9fedb25 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:28:38 +0000 Subject: [PATCH 4/7] Ensure mod::autoindex is added when needed --- manifests/vhost.pp | 4 ++++ spec/defines/vhost_spec.rb | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 8f40af55d..4d528315a 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -2357,6 +2357,10 @@ include apache::mod::auth_gssapi } + if 'index_options' in $directory or 'index_order_default' in $directory or 'index_style_sheet' in $directory { + include apache::mod::autoindex + } + if $directory['provider'] and $directory['provider'] =~ 'location' and ('proxy_pass' in $directory or 'proxy_pass_match' in $directory) { include apache::mod::proxy_http diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 7bdbd8031..827c29e41 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -2258,6 +2258,23 @@ it { is_expected.to contain_class('apache::mod::dav') } it { is_expected.to contain_class('apache::mod::dav_svn') } end + + context 'mod_autoindex is included when needed' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'index_options' => ['FancyIndexing'], + }, + ] + + } + end + + it { is_expected.to compile } + it { is_expected.to contain_class('apache::mod::autoindex') } + end end end end From 797c2b3ff22fa1a26aaed11e752b2349edf5daf6 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:43:05 +0000 Subject: [PATCH 5/7] Ensure mod::cgi is added when needed --- manifests/vhost.pp | 18 +++++++++++ spec/defines/vhost_spec.rb | 64 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 4d528315a..97bbd9f00 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -2336,6 +2336,24 @@ include apache::mod::authz_groupfile } + if 'options' in $directory { + if !('-ExecCGI' in $directory['options']) { + if 'ExecCGI' in $directory['options'] { + case $apache::mpm_module { + 'prefork': { + include apache::mod::cgi + } + 'worker': { + include apache::mod::cgid + } + default: { + # do nothing + } + } + } + } + } + if 'dav' in $directory { include apache::mod::dav if $directory['dav'] == 'On' { diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 827c29e41..0c791aa80 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -2275,6 +2275,70 @@ it { is_expected.to compile } it { is_expected.to contain_class('apache::mod::autoindex') } end + + context 'mod_cgi is included when requested by array' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'options' => ['ExecCGI'], + }, + ] + + } + end + + it { is_expected.to compile } + if os_facts[:os]['family'] == 'Debian' + it { is_expected.not_to contain_class('apache::mod::cgi') } + it { is_expected.to contain_class('apache::mod::cgid') } + else + it { is_expected.to contain_class('apache::mod::cgi') } + it { is_expected.not_to contain_class('apache::mod::cgid') } + end + end + + context 'mod_cgi is included when requested by string' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'options' => 'Indexes ExecCGI', + }, + ] + + } + end + + it { is_expected.to compile } + if os_facts[:os]['family'] == 'Debian' + it { is_expected.not_to contain_class('apache::mod::cgi') } + it { is_expected.to contain_class('apache::mod::cgid') } + else + it { is_expected.to contain_class('apache::mod::cgi') } + it { is_expected.not_to contain_class('apache::mod::cgid') } + end + end + + context 'mod_cgi is not included when unrequested' do + let :params do + { + 'docroot' => '/var/www/foo', + 'directories' => [ + { + 'options' => '+Indexes -ExecCGI', + }, + ] + + } + end + + it { is_expected.to compile } + it { is_expected.not_to contain_class('apache::mod::cgi') } + it { is_expected.not_to contain_class('apache::mod::cgid') } + end end end end From eb5501acc6c2a5a76235ce99b7f7f27320281987 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Sat, 19 Apr 2025 09:11:24 +0000 Subject: [PATCH 6/7] Fix dav logic based on suggestions --- manifests/vhost.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 97bbd9f00..cf16b7780 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -2356,10 +2356,10 @@ if 'dav' in $directory { include apache::mod::dav - if $directory['dav'] == 'On' { - include apache::mod::dav_fs - } elsif $directory['dav'] == 'svn' { + if $directory['dav'] == 'svn' { include apache::mod::dav_svn + } elsif apache::bool2httpd($directory['dav']) == 'On' { + include apache::mod::dav_fs } } From 2bf46b7042f2f8e95fc854de939cec5d3e1ff598 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Wed, 6 Aug 2025 17:55:34 +0000 Subject: [PATCH 7/7] More updates based on review comments Bikeshedding over one if statement, what are we even doing, no wonder we can't get commits merged. --- manifests/vhost.pp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index cf16b7780..772328975 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -2337,18 +2337,16 @@ } if 'options' in $directory { - if !('-ExecCGI' in $directory['options']) { - if 'ExecCGI' in $directory['options'] { - case $apache::mpm_module { - 'prefork': { - include apache::mod::cgi - } - 'worker': { - include apache::mod::cgid - } - default: { - # do nothing - } + if !('-ExecCGI' in $directory['options']) and 'ExecCGI' in $directory['options'] { + case $apache::mpm_module { + 'prefork': { + include apache::mod::cgi + } + 'worker': { + include apache::mod::cgid + } + default: { + # do nothing } } }