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.
More on Playbook Design, Handlers and Idempotency
Your playbook reports `changed` on every run for a task that runs a shell command. How do you fix it?BeginnerNginx must reload only when its config file actually changes.BeginnerA task fails halfway and its handler never ran, but the config file was changed. The next run shows no change and the service never reloads.AdvancedYou need three tasks to notify one handler, and want it to run once. Is that automatic?BeginnerHow do you safely edit one line in `/etc/ssh/sshd_config` and be sure SSH keeps working?IntermediateA task should run only on Debian-family hosts and a different one on RedHat.Beginner