Interview Prep/Ansible/Playbook Design, Handlers and Idempotency

You want to run a task even in check mode, for example to read a version.

IntermediateScenarioPlaybook Design, Handlers and Idempotency
Answer

Situation read → Check mode skips commands, which breaks later logic.

What I'd do →

- ansible.builtin.command: cat /opt/app/VERSION
  register: ver
  check_mode: false
  changed_when: false

Why → check_mode: false forces a real run for a read-only task; changed_when: false keeps the report clean.

Interview tip → Use check_mode: true on a task to force it to be dry-run even in a normal run.

All Ansible questions Roadmap: Ansible

More on Playbook Design, Handlers and Idempotency