Async Zero-Poll vs. Block Timeout: Which Ensures Clean Termination on Playbook Abort?
0 reputation · 26 Jul 2023, 05:53 UTC
Background
Ansible offers two documented mechanisms for limiting long‑running work: async tasks with poll=0 that return a job ID and block-level timeout that aborts a group of tasks after a wall‑clock period.
Goal
When a playbook is interrupted (e.g., Ctrl+C), the user wants any background work to be terminated cleanly, leaving no orphaned processes and ensuring the playbook’s exit status reflects the cancellation.
Uncertainty
Existing documentation notes that async jobs may or may not be killed on playbook abort, and block timeouts are described as cooperative, potentially allowing started tasks to finish. Which approach provides more reliable cleanup?
Questions
- When a playbook is aborted, does an async task with
poll=0terminate automatically, or does it continue to run in the background? - Does a block with a
timeoutguarantee that all child processes are killed when the block is aborted, or can they persist after the abort? - Given the inconsistent behavior across Ansible releases, which documented feature should be preferred for ensuring graceful cancellation of long‑running tasks?