How to set local changed flag only if remote command changes

I have a simple playbook on my servers to update them, and I use another playbook with a command to run that playbook on all the remote servers. Basically I want to set it that the changed flag only occurs when there are changes with the remote playbook, not with the local command (which will always report changes) I am definitely a novice when it comes to ansible so I appreciate any help :slight_smile:

Here is the command:

- hosts:
- Servers
tasks:
- name: Update and upgrade all servers
command: /etc/ansible/ansible-playbook upgrade.yaml

If I add changed_when: false it takes the changed flags away for all, but I would still like it to report if there are any changes with the remote commands if that makes sense.

Have a look at: https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html#overriding-the-changed-result

Example:

  • name: Kill banned services
    shell: “pkill -f {{ item }}”
    with_items: “{{ banned_services }}”
    ignore_errors: yes
    changed_when: False
    failed_when: False