diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 03c86938b..cf16b7780 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,10 +2336,49 @@ 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'] == 'svn' { + include apache::mod::dav_svn + } elsif apache::bool2httpd($directory['dav']) == 'On' { + include apache::mod::dav_fs + } + } + + if 'directoryindex' in $directory { + include apache::mod::dir + } + + if 'expires_active' in $directory { + include apache::mod::expires + } + if 'gssapi' in $directory { 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 b80fd61b0..2be4c0bea 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -2188,6 +2188,157 @@ } 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 + + 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 + + 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 + + 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 + + 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