Skip to content

Detect module dependencies when modules are not default-loaded #2598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2300,6 +2300,7 @@
}

if $fallbackresource {
include apache::mod::dir
$fall_back_res_params = {
'fallbackresource' => $fallbackresource,
}
Expand Down Expand Up @@ -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

Expand Down
151 changes: 151 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading