Bruno Tavares d8e4764ac8 Fixes vhost and vhost::proxy on Precise.
We recently introduced on bf7ce40e2fe7e28dab11ee2fb0ae26a50b5fa8bd the
use of mod_version. The module is enabled and installed by default on
Ubuntu Trusty 14.04, CentOS 6 and CentOS 7.

On Ubuntu Precise 12.04 the module comes installed, but not enabled by
default. This is needed to maintain compatibility with downstream pool
of servers.

Change-Id: I01a8a12b959e3cbecd0355562db0393404ae54bf
Co-Authored-By: Danilo Ramalho <dramalho@thoughtworks.com>
2015-10-20 18:07:41 -02:00

71 lines
1.7 KiB
Puppet

# Define: httpd::vhost::proxy
#
# Configures an apache vhost that will only proxy requests
#
# Parameters:
# * $port:
# The port on which the vhost will respond
# * $dest:
# URI that the requests will be proxied for
# - $priority
# - $template -- the template to use for the vhost
# - $vhost_name - the name to use for the vhost, defaults to '*'
#
# Actions:
# * Install Apache Virtual Host
#
# Requires:
#
# Sample Usage:
#
define httpd::vhost::proxy (
$port,
$dest,
$priority = '10',
$template = 'httpd/vhost-proxy.conf.erb',
$servername = undef,
$serveraliases = undef,
$ssl = false,
$vhost_name = '*',
$proxyexclusions = undef,
$docroot = undef,
) {
include ::httpd
$apache_name = $httpd::params::apache_name
$ssl_path = $httpd::params::ssl_path
if $servername == undef {
$srvname = $name
} else {
$srvname = $servername
}
if $ssl == true {
include ::httpd::ssl
}
# The Apache mod_version module only needs to be enabled on Ubuntu 12.04
# as it comes compiled and enabled by default on newer OS, including CentOS
if !defined(Httpd::Mod['version']) and $::operatingsystem == 'Ubuntu' and $::operatingsystemrelease == '12.04' {
httpd::mod { 'version': ensure => present }
}
file { "${priority}-${name}":
ensure => absent,
path => "${httpd::params::vdir}/${priority}-${name}",
}
file { "${priority}-${name}.conf":
path => "${httpd::params::vdir}/${priority}-${name}.conf",
content => template($template),
owner => 'root',
group => 'root',
mode => '0755',
require => Package['httpd'],
notify => Service['httpd'],
}
}