Task reported as "changed" even if unchanged

Hi,

the following task:

- name: configure systemd-timesyncd - check unit active
  command:
    argv:
      - "systemctl"
      - "is-enabled"
      - "systemd-timesyncd"
  check_mode: no
  register: systemd_timesyncd_unit_enabled

yields a "changed" in the playbook output:

TASK [systemd-timesyncd : configure systemd-timesyncd - check unit active] *****
changed: [news1]
changed: [check]
changed: [slide]

Can I have ansible ignore that and output an "ok" instead for cosmetic reasons
and for statistics?

Greetings
Marc

You can use the changed_when task directive to control when a change is reported. If you want to say this will never create a change set ‘changed_when: false’

Hi,

you should better use systemd module instead of command to do what you intended to do... This module is better at idempotence that command

Command is not idempotent by default, you have to do it (there are different ways to do it), this is why you have some changes

Regards,

Thanks for answering my question, that was helpful!

Greetings
Marc