diff --git a/manifests/init.pp b/manifests/init.pp index 2e288ba..5bcff4b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 diff --git a/manifests/instance.pp b/manifests/instance.pp index d7c9f31..6d2adcf 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -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 # @@ -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'.") @@ -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 @@ -88,6 +114,18 @@ $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 { @@ -95,11 +133,12 @@ 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 \ @@ -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"], } @@ -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, @@ -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': { @@ -198,7 +260,7 @@ apache::vhost { $name: port => $port, - docroot => $doc_root, + docroot => $vhost_root, ensure => 'absent', } } diff --git a/manifests/params.pp b/manifests/params.pp index b015d38..14f7d87 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -21,17 +21,23 @@ # 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', @@ -39,10 +45,10 @@ 'mw-config', 'opensearch_desc.php', 'opensearch_desc.php5', + 'phpcs.xml', 'profileinfo.php', - 'redirect.php', - 'redirect.php5', - 'redirect.phtml', + 'profileinfo.php5', + 'Rakefile', 'resources', 'serialized', 'skins', @@ -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: {