Skip to content

Commit

Permalink
(MODULES-2120) Allow empty docroot
Browse files Browse the repository at this point in the history
README.md updated
If `docroot` and [`manage_docroot`][] are both set to `false`, no
[`DocumentRoot`][] will be set and the accompanying
`<Directory /path/to/directory>` block will not be created.
  • Loading branch information
yakatz committed Oct 9, 2015
1 parent b4885f2 commit f57f7f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
[`logroot`]: #logroot
[Log security]: http://httpd.apache.org/docs/current/logs.html#security

[`manage_docroot`]: #manage_docroot
[`manage_user`]: #manage_user
[`manage_group`]: #manage_group
[`MaxConnectionsPerChild`]: https://httpd.apache.org/docs/current/mod/mpm_common.html#maxconnectionsperchild
Expand Down Expand Up @@ -1886,6 +1887,8 @@ Sets the list of resources to look for when a client requests an index of the di

**Required**. Sets the [`DocumentRoot`][] location, from which Apache serves files.

If `docroot` and [`manage_docroot`][] are both set to `false`, no [`DocumentRoot`][] will be set and the accompanying `<Directory /path/to/directory>` block will not be created.

##### `docroot_group`

Sets group access to the [`docroot`][] directory. Defaults to 'root'.
Expand Down
20 changes: 14 additions & 6 deletions manifests/vhost.pp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@
if $limit_request_field_size {
validate_integer($limit_request_field_size)
}

# Validate the docroot as a string if:
# - $manage_docroot is true
if $manage_docroot {
validate_string($docroot)
}
# Input validation ends

if $ssl and $ensure == 'present' {
Expand Down Expand Up @@ -271,7 +277,7 @@

# This ensures that the docroot exists
# But enables it to be specified across multiple vhost resources
if ! defined(File[$docroot]) and $manage_docroot {
if $manage_docroot and $docroot and ! defined(File[$docroot]) {
file { $docroot:
ensure => directory,
owner => $docroot_owner,
Expand Down Expand Up @@ -443,7 +449,7 @@
fail("Apache::Vhost[${name}]: 'directories' must be either a Hash or an Array of Hashes")
}
$_directories = $directories
} else {
} elsif $docroot {
$_directory = {
provider => 'directory',
path => $docroot,
Expand Down Expand Up @@ -518,10 +524,12 @@
# Template uses:
# - $virtual_docroot
# - $docroot
concat::fragment { "${name}-docroot":
target => "${priority_real}${filename}.conf",
order => 10,
content => template('apache/vhost/_docroot.erb'),
if $docroot {
concat::fragment { "${name}-docroot":
target => "${priority_real}${filename}.conf",
order => 10,
content => template('apache/vhost/_docroot.erb'),
}
}

# Template uses:
Expand Down
2 changes: 1 addition & 1 deletion templates/vhost/_docroot.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
## Vhost docroot
<% if @virtual_docroot -%>
VirtualDocumentRoot "<%= @virtual_docroot %>"
<% else -%>
<% elsif @docroot -%>
DocumentRoot "<%= @docroot %>"
<% end -%>

0 comments on commit f57f7f7

Please sign in to comment.