mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
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>
71 lines
2.9 KiB
YAML
71 lines
2.9 KiB
YAML
---
|
|
- name: "🔍 Matomo install | Check if already installed"
|
|
ansible.builtin.shell: > # nocheck: container-exec-resolver MATOMO_LOCAL_CID resolved at delegate_to runtime; container_address would return a manager-only subshell
|
|
container exec {{ MATOMO_LOCAL_CID | quote }}
|
|
sh -c 'test -f {{ MATOMO_CONFIG | quote }} && grep -q "^\[database\]" {{ MATOMO_CONFIG | quote }} && echo installed || echo fresh'
|
|
register: matomo_install_state
|
|
changed_when: false
|
|
delegate_to: "{{ MATOMO_HOST_NODE }}"
|
|
|
|
- name: "🥾 Bootstrap Matomo (Initialisation and setting of API token if not defined)"
|
|
include_tasks: 04_bootstrap.yml
|
|
when: >
|
|
((matomo_install_state.stdout | trim) != 'installed') or
|
|
((lookup('users', 'administrator').tokens['web-app-matomo'] | default('') | string | trim) == "")
|
|
|
|
- name: "🩹 Patch database credentials for {{ application_id }}"
|
|
include_tasks:
|
|
file: 05_patch_database.yml
|
|
apply:
|
|
delegate_to: "{{ MATOMO_HOST_NODE }}"
|
|
notify: compose-up
|
|
when: (matomo_install_state.stdout | trim) == 'installed'
|
|
|
|
- name: "🩹 Patch Trusted Hosts for {{ application_id }}"
|
|
include_tasks: 06_patch_trusted_hosts.yml
|
|
|
|
- name: 🚿 flush docker service
|
|
meta: flush_handlers
|
|
|
|
- name: "🐝 Matomo install | Swarm: restart matomo so patched config is re-read"
|
|
when: DEPLOYMENT_MODE == 'swarm'
|
|
block:
|
|
- name: "🐝 Matomo install | Swarm: force-restart matomo service"
|
|
ansible.builtin.command: >-
|
|
container service update --force
|
|
{{ lookup('container_service', application_id, MATOMO_SERVICE) }}
|
|
changed_when: true
|
|
timeout: "{{ lookup('timeout', 600) | int }}"
|
|
|
|
- name: "🐝 Matomo install | Swarm: re-resolve hosting node + container ID after restart"
|
|
include_tasks: utils/resolve/host_cid.yml
|
|
|
|
- name: "⏳ Matomo install | Wait for Matomo container to be healthy"
|
|
ansible.builtin.shell: >
|
|
container inspect --type container -f '{{ "{{" }}.State.Health.Status{{ "}}" }}'
|
|
{{ MATOMO_LOCAL_CID | quote }}
|
|
register: matomo_health
|
|
changed_when: false
|
|
retries: 60
|
|
delay: 2
|
|
until: >
|
|
matomo_health.rc == 0 and (matomo_health.stdout | trim) == 'healthy'
|
|
delegate_to: "{{ MATOMO_HOST_NODE }}"
|
|
|
|
- name: "🔐 Matomo install | Make config writable by web user (entrypoint re-owns it root)"
|
|
ansible.builtin.shell: > # nocheck: container-exec-resolver MATOMO_LOCAL_CID resolved at delegate_to runtime; container_address would return a manager-only subshell
|
|
container exec --user root {{ MATOMO_LOCAL_CID | quote }}
|
|
chown www-data:www-data {{ MATOMO_CONFIG }}
|
|
changed_when: true
|
|
delegate_to: "{{ MATOMO_HOST_NODE }}"
|
|
|
|
- name: "🔧 Config '{{ application_id }}' via API"
|
|
include_tasks:
|
|
file: 07_config.yml
|
|
apply:
|
|
delegate_to: "{{ STACK_HOST }}"
|
|
run_once: true
|
|
|
|
- name: "📄 Matomo | Re-render consumer injections after the final compose flush"
|
|
include_tasks: 08_reinject_consumers.yml
|