Files
computer-playbook/roles/sys-svc-compose/tasks/utils/guard_instance_dir.yml
kevinveenbirkenbachandClaude Opus 4.8 6fb4cf462c refactor(sys-svc-compose): delegate manager-only queries to the STACK_HOST SPOT
resolve_host_cid/wait_converged/guard_instance_dir took a run_host parameter every caller had to pass; STACK_HOST already encodes the correct host in both modes (first swarm manager, degrading to inventory_hostname in compose), so the manager-only queries now delegate to it directly and the parameter plus all caller declarations are gone. Also repairs the swarm guard include: apply/delegate_to are invalid on a HandlerTaskInclude and the previous commit carried duplicate run_once/delegate_to keys, which failed the ansible syntax-check. The keycloak handler drops its masking default; the 02b conditional collapses into the SPOT.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 22:18:20 +02:00

19 lines
933 B
YAML

---
- name: "🔍 Stat compose instance dir for '{{ application_id }}'"
ansible.builtin.stat:
path: "{{ lookup('container', application_id, 'directories.instance') }}"
register: sys_svc_compose_instance_dir
changed_when: false
delegate_to: "{{ STACK_HOST }}"
- name: "🛑 Fail: instance dir missing at handler flush for '{{ application_id }}'"
ansible.builtin.fail:
msg: >-
Compose handlers flushed for '{{ application_id }}' but
'{{ lookup('container', application_id, 'directories.instance') }}' does not exist.
A handler notification drifted into a foreign application context: some role switched
application_id (e.g. rendered another app's frontend) between the notify and this flush.
Fix the notifying role: flush handlers while the notifying app is still bound, before
entering the foreign context.
when: not (sys_svc_compose_instance_dir.stat.exists | default(false))