mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 23:08:06 +02:00
web-app-mediawiki: template-driven LocalSettings.php + admin automation; compose & config tweaks
Config & features: - roles/web-app-mediawiki/config/main.yml: - Add sitename ('Wiki on {{ PRIMARY_DOMAIN | upper }}') and meta_namespace ('Meta') - Enable central_database feature and database service - Move volumes under docker.volumes (correct indentation) Tasks & automation: - roles/web-app-mediawiki/tasks/main.yml: - Avoid immediate compose handler flush (docker_compose_flush_handlers: false), then explicit meta: flush_handlers - Deploy templated LocalSettings.php to host path - Create admin via maintenance/createAndPromote.php (docker exec, idempotent changed_when/failed_when) Templates: - roles/web-app-mediawiki/templates/LocalSettings.php.j2: - Set $wgSitename, $wgMetaNamespace, $wgServer from MEDIAWIKI_* - DB settings (mysql, host:port, name, user, password) - Mail settings (EmergencyContact/PasswordSender) - Default skin: vector - Load basic extensions (ParserFunctions, Cite) - roles/web-app-mediawiki/templates/docker-compose.yml.j2: - Switch to MEDIAWIKI_* vars, mount LocalSettings.php (ro) - Use container_port, include curl healthcheck - Fix volumes name to MEDIAWIKI_VOLUME Vars: - roles/web-app-mediawiki/vars/main.yml: - Restructure with MEDIAWIKI_* (sitename, meta_namespace, URL, image/version/container/volume) - Define SETTINGS host/dock paths, container_port, default user (www-data) - Admin bootstrap vars (name/password/email) Misc: - Add empty schema/main.yml placeholder for future validation Refs: ChatGPT conversation (2025-08-28, Europe/Berlin). Link: https://chatgpt.com/share/68b0ace6-f8f4-800f-b7a7-a51a6c5260f1
This commit is contained in:
@@ -1,16 +1,21 @@
|
|||||||
|
sitename: "Wiki on {{ PRIMARY_DOMAIN | upper }}"
|
||||||
|
meta_namespace: "Meta"
|
||||||
server:
|
server:
|
||||||
domains:
|
domains:
|
||||||
canonical:
|
canonical:
|
||||||
- "wiki.{{ PRIMARY_DOMAIN }}"
|
- "wiki.{{ PRIMARY_DOMAIN }}"
|
||||||
docker:
|
docker:
|
||||||
services:
|
services:
|
||||||
|
database:
|
||||||
|
enabled: true
|
||||||
mediawiki:
|
mediawiki:
|
||||||
image: mediawiki
|
image: mediawiki
|
||||||
version: latest
|
version: latest
|
||||||
backup:
|
backup:
|
||||||
no_stop_required: true
|
no_stop_required: true
|
||||||
name: mediawiki
|
name: mediawiki
|
||||||
volumes:
|
volumes:
|
||||||
data: mediawiki_data
|
data: mediawiki_data
|
||||||
features:
|
features:
|
||||||
logout: true
|
logout: true
|
||||||
|
central_database: true
|
||||||
|
0
roles/web-app-mediawiki/schema/main.yml
Normal file
0
roles/web-app-mediawiki/schema/main.yml
Normal file
@@ -2,7 +2,32 @@
|
|||||||
- name: "load docker, db and proxy for {{ application_id }}"
|
- name: "load docker, db and proxy for {{ application_id }}"
|
||||||
include_role:
|
include_role:
|
||||||
name: cmp-db-docker-proxy
|
name: cmp-db-docker-proxy
|
||||||
|
vars:
|
||||||
|
docker_compose_flush_handlers: false
|
||||||
|
|
||||||
- name: add docker-compose.yml
|
- name: "Deploy MediaWiki LocalSettings.php"
|
||||||
template: src=docker-compose.yml.j2 dest={{ docker_compose.directories.instance }}docker-compose.yml
|
template:
|
||||||
notify: docker compose up
|
src: "LocalSettings.php.j2"
|
||||||
|
dest: "{{ MEDIAWIKI_SETTINGS_HOST_PATH }}"
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: "Flush docker compose handlers"
|
||||||
|
meta: flush_handlers
|
||||||
|
|
||||||
|
- name: "Create MediaWiki admin user"
|
||||||
|
command: >
|
||||||
|
docker exec
|
||||||
|
-u {{ MEDIAWIKI_USER }}
|
||||||
|
{{ MEDIAWIKI_CONTAINER }}
|
||||||
|
php /var/www/html/maintenance/createAndPromote.php
|
||||||
|
--bureaucrat --sysop
|
||||||
|
{{ MEDIAWIKI_ADMINISTRATOR_NAME }}
|
||||||
|
{{ MEDIAWIKI_ADMINISTRATOR_PASSWORD }}
|
||||||
|
{{ MEDIAWIKI_ADMINISTRATOR_EMAIL }}
|
||||||
|
register: create_admin
|
||||||
|
changed_when: >
|
||||||
|
'created' in (create_admin.stdout | default('')) or
|
||||||
|
'Created' in (create_admin.stdout | default(''))
|
||||||
|
failed_when: >
|
||||||
|
create_admin.rc != 0 and
|
||||||
|
('already exists' not in (create_admin.stdout | default('') ~ create_admin.stderr | default('')))
|
||||||
|
29
roles/web-app-mediawiki/templates/LocalSettings.php.j2
Normal file
29
roles/web-app-mediawiki/templates/LocalSettings.php.j2
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
# This file was automatically generated by the MediaWiki installer.
|
||||||
|
# Managed by Ansible in your setup.
|
||||||
|
|
||||||
|
# Basic settings
|
||||||
|
$wgSitename = "{{ MEDIAWIKI_SITENAME }}";
|
||||||
|
$wgMetaNamespace = "{{ MEDIAWIKI_META_NAMESPACE }}";
|
||||||
|
$wgScriptPath = "";
|
||||||
|
$wgServer = "{{ MEDIAWIKI_URL }}";
|
||||||
|
|
||||||
|
# Database settings
|
||||||
|
$wgDBtype = "mysql";
|
||||||
|
$wgDBserver = "{{ database_host }}:{{ database_port }}";
|
||||||
|
$wgDBname = "{{ database_name }}";
|
||||||
|
$wgDBuser = "{{ database_username }}";
|
||||||
|
$wgDBpassword = "{{ database_password }}";
|
||||||
|
|
||||||
|
# Email settings
|
||||||
|
$wgEnableEmail = true;
|
||||||
|
$wgEnableUserEmail = true;
|
||||||
|
$wgEmergencyContact = "{{ users.administrator.email }}";
|
||||||
|
$wgPasswordSender = "{{ users['no-reply'].email }}";
|
||||||
|
|
||||||
|
# Default skin
|
||||||
|
$wgDefaultSkin = "vector";
|
||||||
|
|
||||||
|
# Extensions (examples)
|
||||||
|
wfLoadExtension( 'ParserFunctions' );
|
||||||
|
wfLoadExtension( 'Cite' );
|
@@ -1,16 +1,19 @@
|
|||||||
{% include 'roles/docker-compose/templates/base.yml.j2' %}
|
{% include 'roles/docker-compose/templates/base.yml.j2' %}
|
||||||
application:
|
application:
|
||||||
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
||||||
container_name: "{{ mediawiki_name }}"
|
container_name: "{{ MEDIAWIKI_CONTAINER }}"
|
||||||
image: "{{ mediawiki_image }}:{{ mediawiki_version }}"
|
image: "{{ MEDIAWIKI_IMAGE }}:{{ MEDIAWIKI_VERSION }}"
|
||||||
volumes:
|
volumes:
|
||||||
- "data:/var/www/html/"
|
- "data:/var/www/html/"
|
||||||
ports:
|
- "{{ MEDIAWIKI_SETTINGS_HOST_PATH }}:{{ MEDIAWIKI_SETTINGS_DOCK_PATH }}:ro"
|
||||||
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:80"
|
ports:
|
||||||
|
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }}"
|
||||||
|
{% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %}
|
||||||
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
||||||
{% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
|
{% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
|
||||||
|
|
||||||
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
|
{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
|
||||||
data:
|
data:
|
||||||
name: {{ mediawiki_volume }}
|
name: {{ MEDIAWIKI_VOLUME }}
|
||||||
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
|
|
||||||
|
{% include 'roles/docker-compose/templates/networks.yml.j2' %}
|
||||||
|
@@ -1,6 +1,23 @@
|
|||||||
application_id: "web-app-mediawiki"
|
# General
|
||||||
database_type: "mariadb"
|
application_id: "web-app-mediawiki"
|
||||||
mediawiki_version: "{{ applications | get_app_conf(application_id, 'docker.services.mediawiki.version', True) }}"
|
database_type: "mariadb"
|
||||||
mediawiki_image: "{{ applications | get_app_conf(application_id, 'docker.services.mediawiki.image', True) }}"
|
container_port: 80
|
||||||
mediawiki_name: "{{ applications | get_app_conf(application_id, 'docker.services.mediawiki.name', True) }}"
|
|
||||||
mediawiki_volume: "{{ applications | get_app_conf(application_id, 'docker.volumes.data', True) }}"
|
# Mediawiki
|
||||||
|
MEDIAWIKI_SITENAME: "{{ applications | get_app_conf(application_id, 'sitename') }}"
|
||||||
|
MEDIAWIKI_META_NAMESPACE: "{{ applications | get_app_conf(application_id, 'meta_namespace') }}"
|
||||||
|
MEDIAWIKI_URL: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}"
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
MEDIAWIKI_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.mediawiki.version') }}"
|
||||||
|
MEDIAWIKI_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.mediawiki.image') }}"
|
||||||
|
MEDIAWIKI_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.mediawiki.name') }}"
|
||||||
|
MEDIAWIKI_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}"
|
||||||
|
MEDIAWIKI_SETTINGS_HOST_PATH: "{{ [docker_compose.directories.volumes, 'LocalSettings.php'] | path_join }}"
|
||||||
|
MEDIAWIKI_SETTINGS_DOCK_PATH: "/var/www/html/LocalSettings.php"
|
||||||
|
MEDIAWIKI_USER: "www-data"
|
||||||
|
|
||||||
|
# User
|
||||||
|
MEDIAWIKI_ADMINISTRATOR_NAME: "{{ users.administrator.username }}"
|
||||||
|
MEDIAWIKI_ADMINISTRATOR_PASSWORD: "{{ users.administrator.password }}"
|
||||||
|
MEDIAWIKI_ADMINISTRATOR_EMAIL: "{{ users.administrator.email }}"
|
Reference in New Issue
Block a user