feat(web-app-wordpress): add idempotent single-site domain update via WP-CLI

- New task 04_update_domain.yml updates home/siteurl only when needed
- DB-wide search-replace (old → new), GUID-safe, precise, tables-with-prefix
- Normalizes http→https, strips trailing slashes, then flushes cache/rewrites
- Guarded by is_multisite()==0; multisite untouched
- Wired into main.yml with auto target URL via domains|get_url

Fixes post-domain-change mixed/CSP issues due to hard-coded old URLs.

https://chatgpt.com/share/689bac2d-3610-800f-b6f0-41dc79d13a14
This commit is contained in:
2025-08-12 23:03:59 +02:00
parent ce029881d0
commit c744ebe3f9
2 changed files with 83 additions and 0 deletions

View File

@@ -50,3 +50,18 @@
plugin_enabled: "{{ item.value.enabled | bool }}"
plugin_task_path: "{{ role_path }}/tasks/plugins/{{ plugin_name }}/install.yml"
when: plugin_enabled
- name: Detect if WordPress is Multisite
command: >
docker exec -u {{ wordpress_user }} {{ wordpress_container }}
wp eval 'echo (int) is_multisite();' --path={{ wordpress_docker_html_path }}
register: wp_is_multisite
changed_when: false
- name: "Update Single Side Wordpress domain"
include_tasks: 04_update_domain.yml
when: (wp_is_multisite.stdout | trim) == '0'
vars:
# Target URL to switch to (uses your helper)
wp_new_url: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}"