Skip to content
Prev Previous commit
Next Next commit
Allow wikis to be defined by virtual host name
Add instance option that allows a wiki to be accessed through a
unique virtual host name, rather than a unique path.
  • Loading branch information
dspinellis committed Dec 4, 2014
commit 94e84ff54b896f3be64fea2edcd85f2feedeccfc
27 changes: 22 additions & 5 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# [*server_aliases*] - an array of mediawiki web server aliases
# [*ensure*] - the current status of the wiki instance
# - options: present, absent, deleted
# [*vhost_type*] - Whether the wiki will be defined by the name of the
# host or its path
# - options: host, path
# [*server_name*] - Unique server name to use for host-based wikis
#
# === Examples
#
Expand Down Expand Up @@ -44,7 +48,9 @@
$ip = '*',
$port = '80',
$server_aliases = '',
$ensure = 'present'
$ensure = 'present',
$vhost_type = 'path',
$server_name = $mediawiki::server_name,
) {

validate_re($ensure, '^(present|absent|deleted)$',
Expand All @@ -59,13 +65,24 @@
# Make the configuration file more readable
$admin_email = $mediawiki::admin_email
$db_root_password = $mediawiki::db_root_password
$server_name = $mediawiki::server_name
$doc_root = $mediawiki::doc_root
$mediawiki_install_path = $mediawiki::mediawiki_install_path
$mediawiki_conf_dir = $mediawiki::params::conf_dir
$mediawiki_install_files = $mediawiki::params::installation_files
$apache_daemon = $mediawiki::params::apache_daemon

# Configure according to whether the wiki instance will be accessed
# through a unique host name or through a unique path
$vhost_root = $vhost_type ? {
'path' => $doc_root,
'host' => "$doc_root/$name",
}

$script_path = $vhost_type ? {
'path' => "/${name}",
'host' => "''",
}

# Figure out how to improve db security (manually done by
# mysql_secure_installation)
case $ensure {
Expand All @@ -77,7 +94,7 @@
--pass puppet \
--email ${admin_email} \
--server http://${server_name} \
--scriptpath /${name} \
--scriptpath ${script_path} \
--dbtype mysql \
--dbserver localhost \
--installdbuser root \
Expand Down Expand Up @@ -131,7 +148,7 @@
# Each instance has a separate vhost configuration
apache::vhost { $name:
port => $port,
docroot => $doc_root,
docroot => $vhost_root,
serveradmin => $admin_email,
servername => $server_name,
vhost_name => $ip,
Expand Down Expand Up @@ -165,7 +182,7 @@

apache::vhost { $name:
port => $port,
docroot => $doc_root,
docroot => $vhost_root,
ensure => 'absent',
}
}
Expand Down