# How to set local changed flag only if remote command changes

**URL:** <https://forum.ansible.com/t/how-to-set-local-changed-flag-only-if-remote-command-changes/27834>\
**Category:** Ansible Project\
**Created:** [June 20, 2018, 7:25pm UTC](https://forum.ansible.com/t/how-to-set-local-changed-flag-only-if-remote-command-changes/27834 "2018-06-20T19:25:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam\_Lawton](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Sam\_Lawton](https://forum.ansible.com/u/Sam_Lawton)\
**Post date:** [June 20, 2018, 7:25pm UTC](https://forum.ansible.com/t/how-to-set-local-changed-flag-only-if-remote-command-changes/27834/1 "2018-06-20T19:25:46Z")

</div>

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 🙂

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.

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [June 20, 2018, 7:30pm UTC](https://forum.ansible.com/t/how-to-set-local-changed-flag-only-if-remote-command-changes/27834/2 "2018-06-20T19:30:30Z")

</div>

Have a look at: [https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_error\_handling.html#overriding-the-changed-result](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
