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
`