mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
Ansible templates delegate_to before it evaluates the task's when, so a task delegating to N8N_HOST_NODE kills the play with 'N8N_HOST_NODE' is undefined whenever the resolver that sets it was skipped, even though the delegating task would have been skipped too. 43e09ebf0d put the resolver inside the same conditional block. Run 34653754175 shows the pair directly above the failure: the include skipped on the false condition while the setup call had returned status 200, and the play ended at 01_bootstrap.yml:92.
The resolver now runs unconditionally, before the block. It costs one lookup per deploy and changes no state.
The new lint reads the class rather than this instance: a conditional resolve_host_cid include whose PREFIX_HOST_NODE a delegate_to in the same role reads, unless an unconditional resolver or set_fact defines that prefix role-wide. The walker carries the condition through block, rescue and always, so an include nested in a block does not read as unconditional. Against the pre-fix file it reports would flag: ['N8N'].
It found one more: web-app-yourls/tasks/install.yml wrapped its tasks in a block whose when repeated the IS_STACK_HOST condition that main.yml already carries on the include. The wrapper is gone and the tasks are dedented; nothing had broken there because the condition always held.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
30 lines
1.4 KiB
YAML
30 lines
1.4 KiB
YAML
---
|
|
- name: "🔍 Resolve the node that holds '{{ YOURLS_CONTAINER }}' and its local id"
|
|
ansible.builtin.include_tasks: "{{ lookup('path_absolute', 'roles/sys-svc-compose/tasks/utils/swarm/resolve_host_cid.yml') }}"
|
|
vars:
|
|
resolve_service_key: "{{ entity_name }}"
|
|
resolve_output_prefix: YOURLS
|
|
resolve_compose_cid: "{{ YOURLS_CONTAINER_ADDRESS }}"
|
|
|
|
- name: "⏳ Wait until YOURLS is reachable inside {{ YOURLS_CONTAINER }}"
|
|
ansible.builtin.shell:
|
|
cmd: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
|
|
container exec {{ YOURLS_LOCAL_CID | quote }}
|
|
{{ 30 | curl }} -fS -o /dev/null http://127.0.0.1:{{ container_port }}/admin/install.php
|
|
register: yourls_install_probe
|
|
retries: 30
|
|
delay: 2
|
|
until: yourls_install_probe.rc == 0
|
|
changed_when: false
|
|
delegate_to: "{{ YOURLS_HOST_NODE }}"
|
|
|
|
- name: "📁 Create the YOURLS database schema via the installer (idempotent)"
|
|
ansible.builtin.shell:
|
|
cmd: >- # nocheck: container-exec-resolver runtime-resolved CID, delegated to the hosting node
|
|
container exec {{ YOURLS_LOCAL_CID | quote }}
|
|
{{ 300 | curl }} -fS -d install=1 http://127.0.0.1:{{ container_port }}/admin/install.php
|
|
register: yourls_install
|
|
changed_when: "'tables successfully created' in yourls_install.stdout"
|
|
failed_when: yourls_install.rc != 0
|
|
delegate_to: "{{ YOURLS_HOST_NODE }}"
|