mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-15 08:30:46 +02:00
- 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
68 lines
2.2 KiB
YAML
68 lines
2.2 KiB
YAML
---
|
|
- name: "load docker and db for {{application_id}}"
|
|
include_role:
|
|
name: cmp-db-docker
|
|
|
|
- name: "Include role srv-proxy-6-6-domain for {{ application_id }}"
|
|
include_role:
|
|
name: srv-proxy-6-6-domain
|
|
loop: "{{ wordpress_domains }}"
|
|
loop_control:
|
|
loop_var: domain
|
|
vars:
|
|
proxy_extra_configuration: "client_max_body_size {{ wordpress_max_upload_size }};"
|
|
http_port: "{{ ports.localhost.http[application_id] }}"
|
|
|
|
- name: "Transfering upload.ini to {{ docker_compose.directories.instance }}"
|
|
template:
|
|
src: upload.ini.j2
|
|
dest: "{{ docker_compose.directories.instance }}upload.ini"
|
|
notify: docker compose up
|
|
|
|
- name: "Transfering msmtprc to {{ host_msmtp_conf }}"
|
|
template:
|
|
src: "{{ playbook_dir }}/roles/sys-svc-msmtp/templates/msmtprc.conf.j2"
|
|
dest: "{{ host_msmtp_conf }}"
|
|
notify: docker compose up
|
|
|
|
- name: Check if wp-config.php exists in WordPress
|
|
command: docker exec -u {{ wordpress_user }} {{ wordpress_container }} test -f {{ wordpress_docker_html_path }}/wp-config.php
|
|
register: wp_config_file_exists
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Patch WordPress wp-config.php with updated DB credentials
|
|
include_tasks: 01_patch_config.yml
|
|
when: wp_config_file_exists.rc == 0
|
|
|
|
- name: "Install wordpress"
|
|
include_tasks: 02_install.yml
|
|
|
|
- name: "Install and activate WordPress plugins"
|
|
block:
|
|
- name: "Iterate through WordPress plugins"
|
|
include_tasks: 03_enable_plugin.yml
|
|
loop: "{{ wordpress_plugins }}"
|
|
loop_control:
|
|
label: "{{ item.key }}"
|
|
vars:
|
|
plugin_name: "{{ item.key }}"
|
|
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) }}"
|
|
|