Skip to content

Commit 3839c93

Browse files
authored
Merge pull request #2255 from ekohl/include-mods-in-directories
Automatically include modules used in vhost directories
2 parents 8854fbb + 040eab9 commit 3839c93

File tree

15 files changed

+115
-85
lines changed

15 files changed

+115
-85
lines changed

manifests/default_mods.pp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@
157157
}
158158

159159
include apache::mod::authz_user
160-
161-
::apache::mod { 'authz_groupfile': }
160+
include apache::mod::authz_groupfile
162161
include apache::mod::env
163162
} elsif $mods {
164163
::apache::default_mods::load { $mods: }

manifests/mod/authz_groupfile.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# @summary
2+
# Installs `mod_authz_groupfile`
3+
#
4+
# @see https://httpd.apache.org/docs/current/mod/mod_authz_groupfile.html for additional documentation.
5+
#
6+
class apache::mod::authz_groupfile {
7+
include apache
8+
apache::mod { 'authz_groupfile': }
9+
}

manifests/mod/proxy_ajp.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# @see https://httpd.apache.org/docs/current/mod/mod_proxy_ajp.html for additional documentation.
55
#
66
class apache::mod::proxy_ajp {
7-
Class['apache::mod::proxy'] -> Class['apache::mod::proxy_ajp']
7+
require apache::mod::proxy
88
::apache::mod { 'proxy_ajp': }
99
}

manifests/mod/proxy_balancer.pp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
Array $allow_from = ['127.0.0.1','::1'],
2222
Optional[String] $apache_version = $apache::apache_version,
2323
) {
24-
include apache::mod::proxy
25-
include apache::mod::proxy_http
24+
require apache::mod::proxy
25+
require apache::mod::proxy_http
2626
if versioncmp($apache_version, '2.4') >= 0 {
2727
::apache::mod { 'slotmem_shm': }
2828
}
2929

30-
Class['apache::mod::proxy'] -> Class['apache::mod::proxy_balancer']
31-
Class['apache::mod::proxy_http'] -> Class['apache::mod::proxy_balancer']
3230
::apache::mod { 'proxy_balancer': }
3331
if $manager {
3432
include apache::mod::status

manifests/mod/proxy_connect.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
#
55
class apache::mod::proxy_connect {
66
include apache
7-
Class['apache::mod::proxy'] -> Class['apache::mod::proxy_connect']
7+
require apache::mod::proxy
88
apache::mod { 'proxy_connect': }
99
}

manifests/mod/proxy_fcgi.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# @see https://httpd.apache.org/docs/current/mod/mod_proxy_fcgi.html for additional documentation.
55
#
66
class apache::mod::proxy_fcgi {
7-
Class['apache::mod::proxy'] -> Class['apache::mod::proxy_fcgi']
7+
require apache::mod::proxy
88
::apache::mod { 'proxy_fcgi': }
99
}

manifests/mod/proxy_html.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#
66
class apache::mod::proxy_html {
77
include apache
8-
Class['apache::mod::proxy'] -> Class['apache::mod::proxy_html']
9-
Class['apache::mod::proxy_http'] -> Class['apache::mod::proxy_html']
8+
require apache::mod::proxy
9+
require apache::mod::proxy_http
1010

1111
# Add libxml2
1212
case $facts['os']['family'] {

manifests/mod/proxy_http.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
# @see https://httpd.apache.org/docs/current/mod/mod_proxy_http.html for additional documentation.
55
#
66
class apache::mod::proxy_http {
7-
Class['apache::mod::proxy'] -> Class['apache::mod::proxy_http']
7+
require apache::mod::proxy
88
::apache::mod { 'proxy_http': }
99
}

manifests/mod/proxy_wstunnel.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# @see https://httpd.apache.org/docs/current/mod/mod_proxy_wstunnel.html for additional documentation.
55
#
66
class apache::mod::proxy_wstunnel {
7-
include apache, apache::mod::proxy
8-
Class['apache::mod::proxy'] -> Class['apache::mod::proxy_wstunnel']
7+
include apache
8+
require apache::mod::proxy
99
::apache::mod { 'proxy_wstunnel': }
1010
}

manifests/vhost.pp

Lines changed: 68 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,14 @@
428428
# krb_method_negotiate => 'on',
429429
# krb_auth_realms => ['EXAMPLE.ORG'],
430430
# krb_local_user_mapping => 'on',
431-
# directories => {
432-
# path => '/var/www/html',
433-
# auth_name => 'Kerberos Login',
434-
# auth_type => 'Kerberos',
435-
# auth_require => 'valid-user',
436-
# },
431+
# directories => [
432+
# {
433+
# path => '/var/www/html',
434+
# auth_name => 'Kerberos Login',
435+
# auth_type => 'Kerberos',
436+
# auth_require => 'valid-user',
437+
# },
438+
# ],
437439
# }
438440
# ```
439441
#
@@ -1163,9 +1165,12 @@
11631165
# suphp_addhandler => 'x-httpd-php',
11641166
# suphp_engine => 'on',
11651167
# suphp_configpath => '/etc/php5/apache2',
1166-
# directories => { path => '/home/appuser/myphpapp',
1167-
# 'suphp' => { user => 'myappuser', group => 'myappgroup' },
1168-
# }
1168+
# directories => [
1169+
# {
1170+
# 'path' => '/home/appuser/myphpapp',
1171+
# 'suphp' => { user => 'myappuser', group => 'myappgroup' },
1172+
# },
1173+
# ],
11691174
# }
11701175
# ```
11711176
#
@@ -1180,9 +1185,12 @@
11801185
# suphp_addhandler => 'x-httpd-php',
11811186
# suphp_engine => 'on',
11821187
# suphp_configpath => '/etc/php5/apache2',
1183-
# directories => { path => '/home/appuser/myphpapp',
1184-
# 'suphp' => { user => 'myappuser', group => 'myappgroup' },
1185-
# }
1188+
# directories => [
1189+
# {
1190+
# 'path' => '/home/appuser/myphpapp',
1191+
# 'suphp' => { user => 'myappuser', group => 'myappgroup' },
1192+
# },
1193+
# ],
11861194
# }
11871195
# ```
11881196
#
@@ -1197,9 +1205,12 @@
11971205
# suphp_addhandler => 'x-httpd-php',
11981206
# suphp_engine => 'on',
11991207
# suphp_configpath => '/etc/php5/apache2',
1200-
# directories => { path => '/home/appuser/myphpapp',
1201-
# 'suphp' => { user => 'myappuser', group => 'myappgroup' },
1202-
# }
1208+
# directories => [
1209+
# {
1210+
# 'path' => '/home/appuser/myphpapp',
1211+
# 'suphp' => { user => 'myappuser', group => 'myappgroup' },
1212+
# },
1213+
# ],
12031214
# }
12041215
# ```
12051216
#
@@ -1407,10 +1418,12 @@
14071418
# ``` puppet
14081419
# apache::vhost { 'sample.example.net':
14091420
# docroot => '/path/to/directory',
1410-
# directories => {
1411-
# path => '/path/to/directory',
1412-
# headers => 'Set X-Robots-Tag "noindex, noarchive, nosnippet"',
1413-
# },
1421+
# directories => [
1422+
# {
1423+
# path => '/path/to/directory',
1424+
# headers => 'Set X-Robots-Tag "noindex, noarchive, nosnippet"',
1425+
# },
1426+
# ],
14141427
# }
14151428
# ```
14161429
#
@@ -1457,7 +1470,6 @@
14571470
# @param gssapi
14581471
# Specfies mod_auth_gssapi parameters for particular directories in a virtual host directory
14591472
# ```puppet
1460-
# include apache::mod::auth_gssapi
14611473
# apache::vhost { 'sample.example.net':
14621474
# docroot => '/path/to/directory',
14631475
# directories => [
@@ -1804,7 +1816,7 @@
18041816
Boolean $use_servername_for_filenames = false,
18051817
Boolean $use_port_for_filenames = false,
18061818
Array[Hash[String[1], String[1]]] $aliases = [],
1807-
Optional[Variant[Hash, Array[Variant[Array,Hash]]]] $directories = undef,
1819+
Optional[Array[Hash]] $directories = undef,
18081820
Boolean $error_log = true,
18091821
Optional[String] $error_log_file = undef,
18101822
Optional[String] $error_log_pipe = undef,
@@ -2353,7 +2365,41 @@
23532365
# - $apache_version
23542366
# - $suphp_engine
23552367
# - $shibboleth_enabled
2356-
if $_directories and ! empty($_directories) {
2368+
if $_directories and ! empty($_directories) and $ensure == 'present' {
2369+
$_directories.each |Hash $directory| {
2370+
if 'auth_basic_authoritative' in $directory or 'auth_basic_fake' in $directory or 'auth_basic_provider' in $directory {
2371+
include apache::mod::auth_basic
2372+
}
2373+
2374+
if 'auth_user_file' in $directory {
2375+
include apache::mod::authn_file
2376+
}
2377+
2378+
if 'auth_group_file' in $directory {
2379+
include apache::mod::authz_groupfile
2380+
}
2381+
2382+
if 'gssapi' in $directory {
2383+
include apache::mod::auth_gssapi
2384+
}
2385+
2386+
if $directory['provider'] and $directory['provider'] =~ 'location' and ('proxy_pass' in $directory or 'proxy_pass_match' in $directory) {
2387+
include apache::mod::proxy_http
2388+
}
2389+
2390+
if 'request_headers' in $directory {
2391+
include apache::mod::headers
2392+
}
2393+
2394+
if 'rewrites' in $directory {
2395+
include apache::mod::rewrite
2396+
}
2397+
2398+
if 'setenv' in $directory {
2399+
include apache::mod::env
2400+
}
2401+
}
2402+
23572403
concat::fragment { "${name}-directories":
23582404
target => "${priority_real}${filename}.conf",
23592405
order => 60,
@@ -2488,7 +2534,6 @@
24882534
# - $proxy_add_headers
24892535
# - $no_proxy_uris
24902536
if ($proxy_dest or $proxy_pass or $proxy_pass_match or $proxy_dest_match or $proxy_preserve_host) and $ensure == 'present' {
2491-
include apache::mod::proxy
24922537
include apache::mod::proxy_http
24932538

24942539
concat::fragment { "${name}-proxy":

0 commit comments

Comments
 (0)