Files
computer-playbook/roles/web-app-wordpress/tasks/01_patch_config.yml
kevinveenbirkenbachandClaude Opus 5 a46348b6cf refactor(handlers): bind notify to a listen topic, not to a name
A handler name was doing two jobs at once: the line an operator reads in the
play output, and the identifier a `notify:` binds to. The two pull in opposite
directions -- the log wants "restart the SSH service, with diagnostics", the
binding wants a token that survives quoting, YAML flow style and a shell
round-trip -- and a name that changes for readability silently changes which
handler runs.

Every handler that a notify reached by name now carries a `listen:` with that
exact wording, so the binding is explicit before anything is renamed. The
topics themselves become identifiers: `compose up` reads `compose-up`,
`Restart NFS ganesha` reads `restart-nfs-ganesha`, 22 of them across both
sides of every notify. Where the topic is assembled at runtime, both branches
moved together: the conditional in sys-service carries two literals, and the
LDAP renderer interpolates `import-{{ folder }}-ldif-files`, which is what
makes those handlers reachable at all.

Freed from the binding, the names take the emoji prefix every other task line
already has.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 03:38:42 +02:00

43 lines
2.0 KiB
YAML

---
# The seeds need to be executed as root, because www-data isn't allowed to create files in the wordpress directory
- name: "🧹 Strip stale Multisite bareword constants from {{ WORDPRESS_CONFIG_FILE }}"
shell: >
container exec --user root {{ WORDPRESS_CONTAINER_ADDRESS }}
sed -i -E "/^\s*define\(\s*'(DOMAIN_CURRENT_SITE|PATH_CURRENT_SITE)'\s*,.*\);\s*$/d"
{{ WORDPRESS_DOCKER_CONF_PATH }}
changed_when: true
- name: 🔄 Update DB host in {{ WORDPRESS_CONFIG_FILE }}
shell: >
container exec --user root {{ WORDPRESS_CONTAINER_ADDRESS }}
sed -i "s/define(\s*'DB_HOST'\s*,\s*'[^']*'\s*);/define( 'DB_HOST', '{{ lookup('database', application_id, 'host') | sed_escape('/') }}:{{ lookup('database',
application_id, 'port') | sed_escape('/') }}' );/i" {{ WORDPRESS_DOCKER_CONF_PATH }}
notify: compose-up
- name: 🔄 Update DB name in {{ WORDPRESS_CONFIG_FILE }}
shell: >
container exec --user root {{ WORDPRESS_CONTAINER_ADDRESS }}
sed -i "s/define(\s*'DB_NAME'\s*,\s*'[^']*'\s*);/define( 'DB_NAME', '{{ lookup('database', application_id, 'name') | sed_escape('/') }}' );/i" {{ WORDPRESS_DOCKER_CONF_PATH
}}
notify: compose-up
- name: 🔄 Update DB user in {{ WORDPRESS_CONFIG_FILE }}
shell: >
container exec --user root {{ WORDPRESS_CONTAINER_ADDRESS }}
sed -i "s/define(\s*'DB_USER'\s*,\s*'[^']*'\s*);/define( 'DB_USER', '{{ lookup('database', application_id, 'username') | sed_escape('/') }}' );/i" {{ WORDPRESS_DOCKER_CONF_PATH
}}
notify: compose-up
- name: 🔄 Update DB password in {{ WORDPRESS_CONFIG_FILE }}
shell: >
container exec --user root
-e PATCH_PASSWORD={{ lookup('database', application_id, 'password') | sed_escape('/') | quote }}
{{ WORDPRESS_CONTAINER_ADDRESS }}
sh -c "sed -i \"s/define(\\s*'DB_PASSWORD'\\s*,\\s*'[^']*'\\s*);/define( 'DB_PASSWORD', '\${PATCH_PASSWORD}' );/i\" {{ WORDPRESS_DOCKER_CONF_PATH }}"
notify: compose-up
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
- name: "🚿 Flush handlers to reinitialize new database credentials"
meta: flush_handlers