Files
computer-playbook/roles/sys-daemon/handlers/main.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

50 lines
1.2 KiB
YAML

---
- name: 🔍 collect systemd unit files
shell: |
shopt -s nullglob
files=({{ DIR_SYSTEM_SERVICE }}*.service {{ DIR_SYSTEM_SERVICE }}*.timer)
printf "%s\n" "${files[@]}"
args:
executable: /bin/bash
register: _unit_files
changed_when: false
failed_when: false
become: true
listen:
- reload-system-daemon
- reexec-systemd-manager
- name: ✅ validate systemd units
shell: |
systemd-analyze verify {{ _unit_files.stdout_lines | join(' ') }}
register: _verify_units
changed_when: false
failed_when: _unit_files.stdout | length > 0 and _verify_units.rc != 0
become: true
when: _unit_files.stdout | length > 0
listen:
- reload-system-daemon
- reexec-systemd-manager
- name: 🐛 show merged manager config
command: systemd-analyze cat-config systemd/system.conf
register: _catcfg
changed_when: false
become: true
listen:
- reload-system-daemon
- reexec-systemd-manager
- name: "♻️ reload system daemon"
ansible.builtin.systemd:
daemon_reload: true
become: true
listen: reload-system-daemon
- name: 🔄 reexec systemd manager
ansible.builtin.systemd:
daemon_reexec: true
become: true
listen: reexec-systemd-manager
when: not (DOCKER_IN_CONTAINER | bool)