Files
computer-playbook/roles/web-app-wordpress/tasks/03_multisite.yml
kevinveenbirkenbachandClaude Opus 4.8 4039313266 refactor(tasks): enforce and apply a single task-file numbering scheme
Add tests/lint/repository/test_task_file_numbering.py: numbered task
files use exactly two leading digits, a numbered *_core.yml must be
00_core.yml, per directory the numbers are unique/consecutive and start
at 01 (00 with a core file), numbered includes appear in ascending
order, and shared helpers live in tasks/utils/ instead of the numbered
chain.

Apply it across every role: rename NN_core.yml to 00_core.yml with a
consecutive down-shift of the siblings, move letter-suffix children into
a subdirectory named after their parent task, relocate helpers included
from more than one place into tasks/utils/, and update every reference
(include_tasks, path_absolute, .ansible-lint-ignore, requirement docs).
Legacy narration comments in the touched files are deleted; the upstream
xwiki.properties reference block opts out via nocheck. The unused
MAILU_IP6_PUBLIC var (only ever named in now-removed comments) is dropped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 20:01:31 +02:00

80 lines
3.1 KiB
YAML

---
# WordPress Multisite opt-in.
#
# Runs only when `services.wordpress.multisite.enabled` is true.
# Converts the fresh Single-Site installation into a sub-domain Multisite
# network and creates one site per canonical domain beyond the first.
# Domain mapping is handled natively by WordPress core since 4.5.
#
# Idempotent: if the network is already enabled, `wp core multisite-convert`
# prints an informative message and exits 1 - we ignore that so re-runs
# stay green. Sites that already exist are detected via `wp site list`
# before `wp site create` runs.
- name: "🌐 Multisite: convert Single-Site to Multisite network (subdomain install)"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: >
container exec -u {{ WORDPRESS_USER }} {{ WORDPRESS_CONTAINER_ADDRESS }}
wp core multisite-convert
--subdomains
--title="{{ WORDPRESS_TITLE }} Network"
--path="{{ WORDPRESS_DOCKER_HTML_PATH }}"
register: wp_ms_convert
changed_when: wp_ms_convert.rc == 0
failed_when: >
wp_ms_convert.rc != 0
and ('already' not in (wp_ms_convert.stderr | lower))
and ('multisite' not in (wp_ms_convert.stderr | lower))
- name: "🔧 Multisite: patch wp-config.php with PHP-literal constants (--raw)"
shell: >
container exec -u {{ WORDPRESS_USER }} {{ WORDPRESS_CONTAINER_ADDRESS }}
wp config set {{ item.key }} {{ item.value }}
--raw
--type=constant
--path={{ WORDPRESS_DOCKER_HTML_PATH }}
loop:
- { key: "MULTISITE", value: "true" }
- { key: "SUBDOMAIN_INSTALL", value: "true" }
- { key: "SITE_ID_CURRENT_SITE", value: "1" }
- { key: "BLOG_ID_CURRENT_SITE", value: "1" }
changed_when: true
- name: "🔧 Multisite: patch wp-config.php with PHP-string constants (no --raw)"
shell: >
container exec -u {{ WORDPRESS_USER }} {{ WORDPRESS_CONTAINER_ADDRESS }}
wp config set {{ item.key }} {{ item.value }}
--type=constant
--path={{ WORDPRESS_DOCKER_HTML_PATH }}
loop:
- { key: "DOMAIN_CURRENT_SITE", value: "{{ WORDPRESS_DOMAINS | first }}" }
- { key: "PATH_CURRENT_SITE", value: "/" }
changed_when: true
- name: "🌐 Multisite: list the existing sites in the network"
shell: >
container exec -u {{ WORDPRESS_USER }} {{ WORDPRESS_CONTAINER_ADDRESS }}
wp site list --field=url --path={{ WORDPRESS_DOCKER_HTML_PATH }}
register: wp_ms_sites
changed_when: false
- name: "🌐 Multisite: create any missing per-canonical-domain site"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
shell: >
container exec -u {{ WORDPRESS_USER }} {{ WORDPRESS_CONTAINER_ADDRESS }}
wp site create
--slug="{{ item }}"
--title="{{ item }}"
--email="{{ WORDPRESS_ADMIN_EMAIL }}"
--path={{ WORDPRESS_DOCKER_HTML_PATH }}
loop: "{{ (WORDPRESS_DOMAINS | default([]))[1:] }}"
when:
- (WORDPRESS_DOMAINS | default([])) | length > 1
- ('https://' ~ item) not in wp_ms_sites.stdout
- ('http://' ~ item) not in wp_ms_sites.stdout
register: wp_ms_site_create
changed_when: wp_ms_site_create.rc == 0
failed_when: >
wp_ms_site_create.rc != 0
and ('already exists' not in (wp_ms_site_create.stderr | default('') | lower))