Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,22 @@
# Specify dependencies
Class['mysql::server'] -> Class['mediawiki']
#Class['mysql::config'] -> Class['mediawiki']
class { 'apache':
mpm_module => 'prefork',
}
class { 'apache::mod::php': }

ensure_resource('class', 'apache',
{ mpm_module => 'prefork' },
)
ensure_resource('class', 'apache::mod::php')


# Manages the mysql server package and service by default
class { 'mysql::server':
root_password => $db_root_password,
}
ensure_resource('class', 'mysql::server',
{ 'root_password' => $db_root_password },
)

package { $mediawiki::params::packages:
ensure_resource('package', $mediawiki::params::packages, {
ensure => $package_ensure,
}
})

Package[$mediawiki::params::packages] ~> Service<| title == $mediawiki::params::apache |>

# Make sure the directories and files common for all instances are included
Expand Down
82 changes: 72 additions & 10 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
# [*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
# [*admin_name*] - name of the wiki's administrator (admin by default)
# [*admin_password*] - password for the wiki's administrator (puppet by default)
# [*language*] - language to be used for the wiki
#
# === Examples
#
Expand Down Expand Up @@ -56,8 +63,28 @@
$smtp_auth,
$smtp_username,
$smtp_password,
$vhost_type = 'path',
$server_name = $mediawiki::server_name,
$admin_name = 'admin',
$admin_password = 'puppet',
$language = 'en',
$images_dir = '',
$ssl = false,
$ssl_chain = '',
$ssl_key = '',
$ssl_cert = '',
) {


if $port == '' {
if $ssl {
$server_port = 443
} else {
$server_port = 80
}
} else {
$server_port = $port
}

validate_re($ensure, '^(present|absent|deleted)$',
"${ensure} is not supported for ensure.
Allowed values are 'present', 'absent', and 'deleted'.")
Expand All @@ -70,7 +97,6 @@
# 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
Expand All @@ -88,18 +114,31 @@
$wgsmtp = "false"
}

# 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 {
'present', 'absent': {

exec { "${name}-install_script":
cwd => "${mediawiki_install_path}/maintenance",
command => "/usr/bin/php install.php ${name} admin \
--pass puppet \
command => "/usr/bin/php install.php ${name} \
${admin_name} \
--pass ${admin_password} \
--email ${admin_email} \
--server http://${server_name} \
--scriptpath /${name} \
--scriptpath ${script_path} \
--dbtype mysql \
--dbserver localhost \
--installdbuser root \
Expand All @@ -109,7 +148,7 @@
--dbpass ${db_password} \
--db-prefix ${db_prefix} \
--confpath ${mediawiki_conf_dir}/${name} \
--lang en",
--lang ${language}",
creates => "${mediawiki_conf_dir}/${name}/LocalSettings.php",
subscribe => File["${mediawiki_conf_dir}/${name}/images"],
}
Expand Down Expand Up @@ -141,12 +180,31 @@
content => template('mediawiki/DefaultSettings.php.erb'),
}

$images_group = $::operatingsystem ? {
/(?i)(redhat|centos)/ => 'apache',
/(?i)(debian|ubuntu)/ => 'www-data',
default => undef,
}

# Each instance needs a separate folder to upload images
file { "${mediawiki_conf_dir}/${name}/images":
ensure => directory,
group => $apache::params::group,
}


if $images_dir == '' {
file { "${mediawiki_conf_dir}/${name}/images":
ensure => directory,
group => $images_group
}
} else {
file { "${mediawiki_conf_dir}/${name}/images":
ensure => link,
target => $images_dir,
group => $images_group
}
}

# Ensure that mediawiki configuration files are included in each instance.
mediawiki::symlinks { $name:
conf_dir => $mediawiki_conf_dir,
Expand All @@ -163,13 +221,17 @@

# Each instance has a separate vhost configuration
apache::vhost { $name:
port => $port,
docroot => $doc_root,
port => $server_port,
docroot => $vhost_root,
serveradmin => $admin_email,
servername => $server_name,
vhost_name => $ip,
serveraliases => $server_aliases,
ensure => $ensure,
ssl => $ssl,
ssl_chain => $ssl_chain,
ssl_key => $ssl_key,
ssl_cert => $ssl_cert,
}
}
'deleted': {
Expand Down Expand Up @@ -198,7 +260,7 @@

apache::vhost { $name:
port => $port,
docroot => $doc_root,
docroot => $vhost_root,
ensure => 'absent',
}
}
Expand Down
21 changes: 14 additions & 7 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,34 @@
#
class mediawiki::params {

$tarball_url = 'http://releases.wikimedia.org/mediawiki/1.22/mediawiki-1.22.3.tar.gz'
$major = '1.29'
$minor = '1'
$tarball_url = "http://releases.wikimedia.org/mediawiki/$major/mediawiki-$major.$minor.tar.gz"
$conf_dir = '/etc/mediawiki'
$installation_files = ['api.php',
'api.php5',
'autoload.php',
'composer.json',
'docs',
'extensions',
'Gruntfile.js',
'img_auth.php',
'img_auth.php5',
'includes',
'index.php',
'index.php5',
'jsduck.json',
'languages',
'load.php',
'load.php5',
'maintenance',
'mw-config',
'opensearch_desc.php',
'opensearch_desc.php5',
'phpcs.xml',
'profileinfo.php',
'redirect.php',
'redirect.php5',
'redirect.phtml',
'profileinfo.php5',
'Rakefile',
'resources',
'serialized',
'skins',
Expand All @@ -52,25 +58,26 @@
'thumb_handler.php5',
'thumb.php',
'thumb.php5',
'vendor',
'wiki.phtml']

case $::operatingsystem {
redhat, centos: {
$web_dir = '/var/www/html'
$doc_root = "${web_dir}/wikis"
$packages = ['php-gd', 'php-mysql', 'php-xml', 'wget', 'php-pecl-apcu', 'php-intl']
$packages = ['php-gd', 'php-mysql', 'php-xml', 'php-mbstring', 'wget', 'php-pecl-apcu', 'php-intl']
$apache = $apache::params::service_name
}
debian: {
$web_dir = '/var/www'
$doc_root = "${web_dir}/wikis"
$packages = ['php5', 'php5-mysql', 'wget']
$packages = ['php', 'php-mysql', 'php-xml', 'php-mbstring', 'wget']
$apache = $apache::params::service_name
}
ubuntu: {
$web_dir = '/var/www'
$doc_root = "${web_dir}/wikis"
$packages = ['php5', 'php5-mysql', 'wget']
$packages = ['php', 'php-mysql', 'php-xml', 'php-mbstring', 'wget']
$apache = $apache::params::service_name
}
default: {
Expand Down