mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
The pre-pull hardcoded its `async:` value while `poll:` resolved to `omit` whenever async is disabled. The job therefore stayed asynchronous but Ansible polled it to completion itself and removed the job file, so the shared reaper died with `could not find job`, naming a different job id on every run. Gate `async:` the way the other seven reaper callers already do, and skip the reaper itself when async is off, so no caller can reap jobs that were never started asynchronously. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
29 lines
1.2 KiB
YAML
29 lines
1.2 KiB
YAML
---
|
|
# Param: async_reap_jobs registered results to collect: a looped task's `.results`,
|
|
# or `[task_result]` for a single task
|
|
# Param: async_reap_label what is being collected, used in the messages
|
|
# Param: async_reap_tolerate list of substrings in a job's msg that count as success
|
|
# (an already-exists answer from an idempotent API), [] when none
|
|
- name: "⏳ Collect async results: {{ async_reap_label }}"
|
|
ansible.builtin.async_status:
|
|
jid: "{{ item.ansible_job_id }}"
|
|
loop: "{{ async_reap_jobs | selectattr('ansible_job_id', 'defined') | list }}"
|
|
loop_control:
|
|
label: "{{ item.ansible_job_id }}"
|
|
register: async_reap_results
|
|
until: async_reap_results.finished
|
|
retries: "{{ ((ASYNC_TIME | int) / 5) | round(0, 'ceil') | int }}"
|
|
delay: 5
|
|
changed_when: false
|
|
failed_when: false
|
|
when: ASYNC_ENABLED | bool
|
|
|
|
- name: "🛑 Fail if any async job of {{ async_reap_label }} failed"
|
|
vars:
|
|
_broken: "{{ async_reap_results.results | default([]) | async_failures(async_reap_tolerate) }}"
|
|
ansible.builtin.fail:
|
|
msg: >-
|
|
{{ async_reap_label }}: {{ _broken | length }} async job(s) failed:
|
|
{{ _broken | join(' || ') }}
|
|
when: ASYNC_ENABLED | bool and _broken | length > 0
|