fail("Apache::Vhost[${name}]: must pass 'ip' and/or 'port' parameters for name-based vhosts")
}
}
} else {
if $port {
$listen_addr_port = $port
$nvh_addr_port = "${vhost_name}:${port}"
} else {
$nvh_addr_port = $name
if ! $servername {
fail("Apache::Vhost[${name}]: must pass 'ip' and/or 'port' parameters, and/or 'servername' parameter")
}
}
}
if $add_listen {
if $ip and defined(Apache::Listen[$port]) {
fail("Apache::Vhost[${name}]: Mixing IP and non-IP Listen directives is not possible; check the add_listen parameter of the apache::vhost define to disable this")
}
if ! defined(Apache::Listen[$listen_addr_port]) and $listen_addr_port and $ensure == 'present' {
apache::listen { $listen_addr_port: }
}
}
if ! $ip_based {
if ! defined(Apache::Namevirtualhost[$nvh_addr_port]) and $ensure == 'present' {
apache::namevirtualhost { $nvh_addr_port: }
}
}
# Load mod_rewrite if needed and not yet loaded
if $rewrites or $rewrite_cond {
if ! defined(Apache::Mod['rewrite']) {
apache::mod { 'rewrite': }
}
}
# Load mod_alias if needed and not yet loaded
if ($scriptalias or $scriptaliases != []) or ($redirect_source and $redirect_dest) {
if ! defined(Class['apache::mod::alias']) {
include apache::mod::alias
}
}
# Load mod_proxy if needed and not yet loaded
if ($proxy_dest or $proxy_pass) {
if ! defined(Class['apache::mod::proxy']) {
include apache::mod::proxy
}
if ! defined(Class['apache::mod::proxy_http']) {
include apache::mod::proxy_http
}
}
# Load mod_passenger if needed and not yet loaded
if $rack_base_uris {
if ! defined(Class['apache::mod::passenger']) {
include apache::mod::passenger
}
}
# Load mod_fastci if needed and not yet loaded
if $fastcgi_server and $fastcgi_socket {
if ! defined(Class['apache::mod::fastcgi']) {
include apache::mod::fastcgi
}
}
# Configure the defaultness of a vhost
if $priority {
$priority_real = $priority
} elsif $default_vhost {
$priority_real = '10'
} else {
$priority_real = '25'
}
# Check if mod_headers is required to process $headers/$request_headers
if $headers or $request_headers {
if ! defined(Class['apache::mod::headers']) {
include apache::mod::headers
}
}
## Apache include does not always work with spaces in the filename
$filename = regsubst($name, ' ', '_', 'G')
## Create a default directory list if none defined
if $directories {
$_directories = $directories
} else {
$_directories = [ {
provider => 'directory',
path => $docroot,
options => $options,
allow_override => $override,
directoryindex => $directoryindex,
order => 'allow,deny',
allow => 'from all',
} ]
}
# Template uses:
# - $nvh_addr_port
# - $servername
# - $serveradmin
# - $docroot
# - $virtual_docroot
# - $options
# - $override
# - $logroot
# - $name
# - $aliases
# - $_directories
# - $log_level
# - $access_log
# - $access_log_destination
# - $_access_log_format
# - $_access_log_env_var
# - $error_log
# - $error_log_destination
# - $error_documents
# - $fallbackresource
# - $custom_fragment
# - $additional_includes
# block fragment:
# - $block
# directories fragment:
# - $passenger_enabled
# - $php_admin_flags
# - $php_admin_values
# - $directories (a list of key-value hashes is expected)