# no change notify

**URL:** <https://forum.ansible.com/t/no-change-notify/14687>\
**Category:** Ansible Project\
**Created:** [March 3, 2014, 6:55pm UTC](https://forum.ansible.com/t/no-change-notify/14687 "2014-03-03T18:55:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [March 3, 2014, 6:55pm UTC](https://forum.ansible.com/t/no-change-notify/14687/1 "2014-03-03T18:55:56Z")

</div>

Is it possible to notify handler if task didn’t change anything?  
I’m creating a backup prior to executing a task, and want to  
remove it if nothing changed. Currently I do it like so:

`

- command: cp {{backsrc}} {{backdst}}

- apt\_repository: repo=“{{ item }}” state=absent update\_cache=false  
register: aptrem  
with\_items: reporem

- apt\_repository: repo=“{{ item }}” state=present update\_cache=false  
register: aptadd  
with\_items: repoadd

- command: rm {{backdst}}  
when: aptrem.changed == 0 and aptadd.changed == 0

- apt: update\_cache=true  
when: aptrem.changed != 0 or aptadd.changed != 0  
`

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 3, 2014, 7:00pm UTC](https://forum.ansible.com/t/no-change-notify/14687/2 "2014-03-03T19:00:35Z")

</div>

You could use the changed\_when: keyword to set when a task should be seen as ‘changed’

changed\_when: not aptrem.changed

perhaps?

---

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [March 3, 2014, 7:04pm UTC](https://forum.ansible.com/t/no-change-notify/14687/3 "2014-03-03T19:04:40Z")

</div>

changes status is set correctly. I just want to know if it is possible  
to use handler + notify instead of passing the state through a variable.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [March 3, 2014, 7:11pm UTC](https://forum.ansible.com/t/no-change-notify/14687/4 "2014-03-03T19:11:08Z")

</div>

Handlers get triggered on a changed state, from what you said, you want to  
trigger it when 'not changed', so hence my example.  
There's no way to trigger a handler while keeping the changed: false state.

I'll agree that the changed states get weird in this case :)​

Serge

---

<div class="post-metadata">

**Author:** ![anatoly\_techtonik](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@anatoly\_techtonik](https://forum.ansible.com/u/anatoly_techtonik)\
**Post date:** [March 3, 2014, 7:26pm UTC](https://forum.ansible.com/t/no-change-notify/14687/5 "2014-03-03T19:26:07Z")

</div>

Yes. I better keep my approach. =)
