From 8ebb118b50c9e6b09d54499b09574c2547fe7251 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 06:52:58 +0000 Subject: [PATCH 1/6] 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 b80fd61b0..875963427 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 7c4cdbae2dbbb9575a23425d072942201bd222dc Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:01:22 +0000 Subject: [PATCH 2/6] 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 875963427..85fff41fc 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 5c51faa23f415dfd99cb56e04fce5c1a6fb4fa34 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:20:22 +0000 Subject: [PATCH 3/6] 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 85fff41fc..a049c7097 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 7c23338b750bc50318b89da00c5f4e09e0314325 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:28:38 +0000 Subject: [PATCH 4/6] 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 a049c7097..00897dace 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 6426552dd593a801a2ab370af0bf76d6c057f394 Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Thu, 3 Apr 2025 07:43:05 +0000 Subject: [PATCH 5/6] 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 00897dace..2be4c0bea 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 8325f5fdb3740b47b4b471284d4a4ab3a018b14e Mon Sep 17 00:00:00 2001 From: Greg Cox Date: Sat, 19 Apr 2025 09:11:24 +0000 Subject: [PATCH 6/6] 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 } }