Interview Prep/Ansible/Playbook Design, Handlers and Idempotency

You need to deploy a binary only if it is missing or its checksum differs.

IntermediateScenarioPlaybook Design, Handlers and Idempotency
Answer

Situation read → Make a download idempotent.

What I'd do →

- ansible.builtin.get_url:
    url: "https://releases.example.com/app-{{ app_version }}.tar.gz"
    dest: /opt/app/app-{{ app_version }}.tar.gz
    checksum: "sha256:{{ app_sha256 }}"
    mode: "0644"

Why → get_url with checksum downloads only when the destination is absent or differs, and verifies integrity.

Interview tip → Versioned file names give you free rollbacks.

All Ansible questions Roadmap: Ansible

More on Playbook Design, Handlers and Idempotency