I want to pass a variable to a notification handler, but can\'t find anywhere be it here on SO, the docs or the issues in the github repo, how to do it. What I\'m doing is d
To update jarv's answer above, Ansible 2.5 replaces with_items
with loop
. When getting results, item
by itself will not work. You will need to explicitly get the name, e.g., item.name
.
- hosts: localhost
tasks:
- file: >
path=/tmp/{{ item }}
state=directory
register: files_created
loop:
- one
- two
notify: some_handler
handlers:
- name: "some_handler"
shell: "echo {{ item.name }} has changed!"
when: item.changed
loop: files_created.results