Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8396457
vhost.pp
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
vhost.pp
View Options
# Definition: apache::vhost
#
# This class installs Apache Virtual Hosts
#
# Parameters:
# - The $port to configure the host on
# - The $docroot provides the DocumentationRoot variable
# - The $serveradmin will specify an email address for Apache that it will display when it renders one of it's error pages
# - The $configure_firewall option is set to true or false to specify if
# a firewall should be configured.
# - The $ssl option is set true or false to enable SSL for this Virtual Host
# - The $template option specifies whether to use the default template or
# override
# - The $priority of the site
# - The $servername is the primary name of the virtual host
# - The $serveraliases of the site
# - The $options for the given vhost
# - The $vhost_name for name based virtualhosting, defaulting to *
# - The $logroot specifies the location of the virtual hosts logfiles, default to /var/log/<apache log location>/
#
# Actions:
# - Install Apache Virtual Hosts
#
# Requires:
# - The apache class
#
# Sample Usage:
# apache::vhost { 'site.name.fqdn':
# priority => '20',
# port => '80',
# docroot => '/path/to/docroot',
# }
#
define
apache
::
vhost
(
$port,
$docroot,
$serveradmin,
$configure_firewall
=
true
,
$ssl
=
$apache::params::ssl,
$template
=
$apache::params::template,
$priority
=
$apache::params::priority,
$servername
=
$apache::params::servername,
$serveraliases
=
$apache::params::serveraliases,
$auth
=
$apache::params::auth,
$redirect_ssl
=
$apache::params::redirect_ssl,
$options
=
$apache::params::options,
$apache_name
=
$apache::params::apache_name,
$vhost_name
=
$apache::params::vhost_name,
$logroot
=
"/var/log/$apache::params::apache_name"
)
{
include
apache
if
$servername
==
''
{
$srvname
=
$name
}
else
{
$srvname
=
$servername
}
if
$ssl
==
true
{
include
apache
::
ssl
}
# Since the template will use auth, redirect to https requires mod_rewrite
if
$redirect_ssl
==
true
{
case
$::operatingsystem
{
'debian'
,
'ubuntu'
:
{
A2mod
<|
title
==
'rewrite'
|>
}
default
:
{
}
}
}
# This ensures that the docroot exists
# But enables it to be specified across multiple vhost resources
if
!
defined
(
File
[
$docroot])
{
file
{
$docroot:
ensure
=>
directory
,
}
}
# Same as above, but for logroot
if
!
defined
(
File
[
$logroot])
{
file
{
$logroot:
ensure
=>
directory
,
}
}
file
{
"${priority}-${name}.conf"
:
path
=>
"${apache::params::vdir}/${priority}-${name}.conf"
,
content
=>
template
(
$template),
owner
=>
'root'
,
group
=>
'root'
,
mode
=>
'0755'
,
require
=>
[
Package
[
'httpd'
],
File
[
$docroot],
File
[
$logroot],
],
notify
=>
Service
[
'httpd'
],
}
if
$configure_firewall
{
if
!
defined
(
Firewall
[
"0100-INPUT ACCEPT $port"
])
{
@
firewall
{
"0100-INPUT ACCEPT $port"
:
action
=>
'accept'
,
dport
=>
$port,
proto
=>
'tcp'
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Jun 4 2025, 7:53 PM (13 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3399426
Attached To
rSPAPA puppet-puppetlabs-apache
Event Timeline
Log In to Comment