Interview Prep/Ansible/Playbook Design, Handlers and Idempotency

You need to retry a flaky task, like a package mirror, up to five times.

BeginnerScenarioPlaybook Design, Handlers and Idempotency
Answer

Situation read → Transient network failures.

What I'd do →

- ansible.builtin.apt: { name: nginx, update_cache: true }
  register: r
  retries: 5
  delay: 10
  until: r is succeeded

Why → until re-evaluates after each attempt; delay avoids hammering the mirror.

Interview tip → Retries mask real problems if overused; log and alert on repeated retries.

All Ansible questions Roadmap: Ansible

More on Playbook Design, Handlers and Idempotency