Files
computer-playbook/roles/sys-svc-container/tasks/03_reset.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

23 lines
941 B
YAML

---
- name: 📊 Gather containers
community.docker.docker_host_info: # nocheck: docker-module-uses-container-cli read-only info module; returns structured container facts the wrapper's raw JSON would need parsed
containers: true
register: docker_info
- name: 🗑️ Remove containers (stops running ones)
ansible.builtin.command: "container rm -f {{ (item.Names | default([item.Name]))[0] | regex_replace('^/','') }}"
register: reset_container_rm
loop: "{{ docker_info.containers }}"
loop_control:
label: "{{ (item.Names | default([item.Name]))[0] }}"
when: docker_info.containers | length > 0
changed_when: reset_container_rm.rc == 0
failed_when: >-
reset_container_rm.rc != 0 and
'No such container' not in (reset_container_rm.stderr | default(''))
- name: ⚡ Trigger Docker restart
ansible.builtin.debug:
msg: "MODE_RESET is enabled → restarting Docker"
notify: container-manager-restart