Files
computer-playbook/roles/sys-svc-dns/tasks/01_apex.yml
kevinveenbirkenbachandClaude Opus 5 cd1225d2d9 fix(async): collect fire-and-forget results
The repo's async convention is fire and forget: ASYNC_POLL is 0 whenever
ASYNC_ENABLED is true, and the swarm test lane forces it true through
extra vars. A task dispatched that way returns a stub, so a changed_when
or failed_when reading its own register evaluates against nothing and can
never report changed and never fail. Several tasks carried a
"not ASYNC_ENABLED and" prefix in front of those conditions, added to
avoid touching undefined rc and stdout, which turned the guard off
entirely rather than adapting it.

That is how the nextcloud plugin configuration stayed broken unseen: the
batch reported ok after 0.8s while its delegated commands kept running,
the next task read the half written configuration, and no failure in any
of them could surface.

Every async in the repo was decided individually rather than swept. Where
nothing consumes the result, the async stays and a one line rationale now
records what does not read it. Where a later task, a handler or a browser
does consume it, either the async goes or the result is collected.

Collecting is what the new reaper does. It waits for a whole batch, then
reports every broken job at once instead of aborting on the first, so one
run shows whether a single item or the whole set is broken. Deciding what
counts as broken lives in a filter plugin, because the distinction is
subtle enough to deserve tests: a module reports failure in msg, a command
in rc and stdout, an idempotent API answers "already exists" and means
success, and a job that cannot be read at all comes back marked finished
with no outcome, which would otherwise read as green.

Timing cost is roughly one to two minutes on a deploy measured in hours.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 04:05:38 +02:00

31 lines
1.1 KiB
YAML

---
- name: "✅ Ensure A @ for {{ base_domain }}"
community.general.cloudflare_dns:
api_token: "{{ lookup('api', 'cloudflare.api_token') }}"
zone: "{{ base_domain }}"
type: A
name: "@"
content: "{{ networks.internet.ip4 }}"
proxied: false
ttl: 1
state: present
# rationale: async; no register and no notify, the sibling AAAA and CAA write other record types
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
- name: "✅ AAAA @ for {{ base_domain }} = {{ networks.internet.ip6 | default('None') }}"
community.general.cloudflare_dns:
api_token: "{{ lookup('api', 'cloudflare.api_token') }}"
zone: "{{ base_domain }}"
type: AAAA
name: "@"
content: "{{ networks.internet.ip6 }}"
proxied: false
ttl: 1
state: present
when:
- (networks.internet.ip6 | default('') | trim) != ''
# rationale: async; last task of the file, no register and no notify, nothing reads AAAA back
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"