web-app-mediawiki: ensure container is up before extension install; guard OIDC bootstrap

- Trigger docker compose up after rendering LocalSettings/oidc/debug configs
- Flush handlers and wait for MediaWiki container to exist before running docker exec/cp
- Prevent fatal errors during provisioning by loading OIDC extensions only if extension.json files exist

https://chatgpt.com/share/6968d779-263c-800f-b40b-7ee8e525268d
This commit is contained in:
kevinveenbirkenbach committed 2026-01-15 13:02:59 +01:00
1 parent d9ef2cd500
commit a54b7dab11
4 files changed
+56 -25

No files matched your search

+2 -1
View File
@@ -16,7 +16,7 @@
src: "{{ cfg.src }}"
dest: "{{ cfg.dest }}"
owner: root
group: "{{ MEDIAWIKI_USER_GID }}" # www-data
group: "{{ MEDIAWIKI_USER_GID }}"
mode: "0640"
loop:
- src: "oidc.php.j2"
@@ -34,3 +34,4 @@
when: cfg.when | bool
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
register: mediawiki_config_render
notify: docker compose up
@@ -70,8 +70,8 @@
executable: /bin/bash
register: _tools
changed_when: "'INSTALLED_TOOLS' in (_tools.stdout | default(''))"
notify: docker compose up
# Ensure Composer is available inside the container (idempotent)
- name: "EXT | Ensure Composer available in container"
shell: |
docker exec {{ MEDIAWIKI_CONTAINER }} bash -lc '
+23
View File
@@ -8,6 +8,19 @@
- name: "Load install procedures for '{{ application_id }}''"
include_tasks: 01_install.yml
- name: "flush handlers for '{{ application_id }}' after installation finished"
meta: flush_handlers
- name: "MEDIAWIKI | Wait until container exists"
shell: "docker inspect {{ MEDIAWIKI_CONTAINER }} >/dev/null 2>&1"
args:
executable: /bin/bash
register: _mw_exists
retries: 20
delay: 1
until: _mw_exists.rc == 0
changed_when: false
- name: "Load extensions procedures for '{{ application_id }}''"
include_tasks: "02_extensions.yml"
when: MEDIAWIKI_OIDC_ENABLED | bool
@@ -15,6 +28,16 @@
- name: "flush handlers for '{{ application_id }}' after preparation finished"
meta: flush_handlers
- name: "MEDIAWIKI | Wait until container exists"
shell: "docker inspect {{ MEDIAWIKI_CONTAINER }} >/dev/null 2>&1"
args:
executable: /bin/bash
register: _mw_exists
retries: 20
delay: 1
until: _mw_exists.rc == 0
changed_when: false
- name: "Load update procedures for '{{ application_id }}''"
include_tasks: 03_update.yml
when: >-
+30 -23
View File
@@ -3,32 +3,39 @@
{% if MEDIAWIKI_OIDC_ENABLED | bool %}
{% if 'web-svc-logout' in CURRENT_PLAY_APPLICATIONS %}
# The cookie deletion of the logout app leads to a login bug if this isn't set
$wgPasswordAttemptThrottle = [];
{% endif %}
$pa = "$IP/extensions/PluggableAuth/extension.json";
$oidc = "$IP/extensions/OpenIDConnect/extension.json";
wfLoadExtension( 'PluggableAuth' );
wfLoadExtension( 'OpenIDConnect' );
if ( file_exists( $pa ) && file_exists( $oidc ) ) {
$wgPluggableAuth_EnableAutoLogin = {{ MEDIAWIKI_OIDC_AUTOLOGIN | bool | ternary('true','false') }};
$wgPluggableAuth_EnableLocalLogin = {{ MEDIAWIKI_OIDC_LOCALLOGIN | bool | ternary('true','false') }};
$wgPluggableAuth_ButtonLabel = '{{ MEDIAWIKI_OIDC_BUTTON_TEXT }}';
{% if 'web-svc-logout' in CURRENT_PLAY_APPLICATIONS %}
$wgPasswordAttemptThrottle = [];
{% endif %}
$wgPluggableAuth_Config = [
[
'plugin' => 'OpenIDConnect',
'data' => [
'providerURL' => '{{ MEDIAWIKI_OIDC_ISSUER }}',
'clientID' => '{{ MEDIAWIKI_OIDC_CLIENT_ID }}',
'clientsecret' => '{{ MEDIAWIKI_OIDC_CLIENT_SECRET }}',
'scope' => [ 'openid', 'profile', 'email' ],
wfLoadExtension( 'PluggableAuth' );
wfLoadExtension( 'OpenIDConnect' );
$wgPluggableAuth_EnableAutoLogin = {{ MEDIAWIKI_OIDC_AUTOLOGIN | bool | ternary('true','false') }};
$wgPluggableAuth_EnableLocalLogin = {{ MEDIAWIKI_OIDC_LOCALLOGIN | bool | ternary('true','false') }};
$wgPluggableAuth_ButtonLabel = '{{ MEDIAWIKI_OIDC_BUTTON_TEXT }}';
$wgPluggableAuth_Config = [
[
'plugin' => 'OpenIDConnect',
'data' => [
'providerURL' => '{{ MEDIAWIKI_OIDC_ISSUER }}',
'clientID' => '{{ MEDIAWIKI_OIDC_CLIENT_ID }}',
'clientsecret' => '{{ MEDIAWIKI_OIDC_CLIENT_SECRET }}',
'scope' => [ 'openid', 'profile', 'email' ],
],
],
],
];
];
$wgOpenIDConnect_UseEmailNameAsUserName = true;
$wgOpenIDConnect_MigrateUsers = true;
// ### OIDC (PluggableAuth) – END
$wgOpenIDConnect_UseEmailNameAsUserName = true;
$wgOpenIDConnect_MigrateUsers = true;
{% endif %}
} else {
// Extensions not present yet; skip OIDC bootstrap to avoid fatal errors during provisioning.
}
{% endif %}