Interview Prep/Ansible/Playbook Design, Handlers and Idempotency

A command returns exit code 2 for "nothing to do", which Ansible counts as failure.

IntermediateScenarioPlaybook Design, Handlers and Idempotency
Answer

Situation read → Tool semantics differ from Ansible's default rc != 0 rule.

What I'd do →

- ansible.builtin.command: /usr/local/bin/sync-tool
  register: r
  failed_when: r.rc not in [0, 2]
  changed_when: r.rc == 0

Why → failed_when and changed_when let you encode the tool's real contract.

Interview tip → Prefer an official module; custom conditions are the fallback.

All Ansible questions Roadmap: Ansible

More on Playbook Design, Handlers and Idempotency