Why do read-only command tasks often get changed_when: false?
command and shell can't tell whether they changed anything, so they always report changed; changed_when: false makes a task that only reads (like a config syntax check) report ok instead.
- name: Validate httpd configuration
ansible.builtin.command: httpd -t
changed_when: false
register: httpd_config_status
httpd -t only checks the Apache configuration syntax; nothing on the host changes. Ansible doesn't know that: it just ran an arbitrary command, so by default it reports changed every time.
That default has three costs. The play recap shows changes on every run, so you lose the "a second run reports zero changes" signal of an idempotent playbook. Any handler the task notifies would fire every time. And --check runs become noisy. changed_when: false fixes all three: the task reports only ok or failed, and later tasks can still use httpd_config_status.
Go deeper:
Defining changed (official docs) — overriding the changed status.
ansible.builtin.command module (official docs) — why it can't detect changes, and its
creates/removesoptions.