You could use the changed_when: keyword to set when a task should be seen as 'changed'
changed_when: not aptrem.changed perhaps? On 3 March 2014 19:55, anatoly techtonik <[email protected]> wrote: > 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 > > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/8c6f7445-646b-4963-85fb-aa4372010c68%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAEhzMJCS1H8AA%3DJ1_RxjMvdu8UmWqFfMdhLyiC5yaKjgPe1NiA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
