Interview Prep/Ansible/Rolling Updates, Delegation and Orchestration

How do you run a long job (a 45-minute backup) on many hosts without holding SSH sessions?

AdvancedScenarioRolling Updates, Delegation and Orchestration
Answer

Situation read → Long tasks and connection timeouts.

What I'd do →

- ansible.builtin.command: /opt/backup/run.sh
  async: 3600
  poll: 0
  register: job
- ansible.builtin.async_status:
    jid: "{{ job.ansible_job_id }}"
  register: res
  until: res.finished
  retries: 120
  delay: 30

Why → poll: 0 fires and forgets, and async_status checks later, so no session is held open between polls.

Interview tip → async tasks do not work with check mode and some connection types.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Orchestration