# Notify based on with\_items variable

**URL:** <https://forum.ansible.com/t/notify-based-on-with-items-variable/16328>\
**Category:** Ansible Project\
**Created:** [September 24, 2014, 8:57pm UTC](https://forum.ansible.com/t/notify-based-on-with-items-variable/16328 "2014-09-24T20:57:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Wolstenholme](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@Paul\_Wolstenholme](https://forum.ansible.com/u/Paul_Wolstenholme)\
**Post date:** [September 24, 2014, 8:57pm UTC](https://forum.ansible.com/t/notify-based-on-with-items-variable/16328/1 "2014-09-24T20:57:15Z")

</div>

I’m using the template module and would like loop through a bunch of templates for configuration files and execute and handler if need be. I tried the following. And, it failed. I thought it would be cool to avoid descrete template plays for each service.

- name: Push NRPE configuration files  
template:  
src={{item.j2}}  
dest={{item.dest}}  
mode={{item.mode}}  
backup=yes  
register: nrpe  
notify: {{item.handler}}  
with\_items:
- { j2: “smartos\_setup.sh.j2”, dest: “{{smartos\_custom}}/share/svc/smartos\_setup.sh”, mode: ‘0755’, handler: ‘setup-reload’ }
- { j2: “nrpe.cfg.j2”, dest: “{{smartos\_custom}}/etc/nrpe.cfg”, mode: ‘0644’, handler: ‘nrpe-reload’ }  
tags: smartos\_global

Result:

ok: [smartos01] =\> (item={‘dest’: u’/opt/custom/smf/nrpe/manifest.xml’, ‘handler’: ‘nrpe-reload’, ‘mode’: ‘0644’, ‘j2’: ‘nrpe-manifest.xml.j2’})  
changed: [smartos01] =\> (item={‘dest’: u’/opt/custom/etc/nrpe.cfg’, ‘handler’: ‘nrpe-reload’, ‘mode’: ‘0644’, ‘j2’: ‘nrpe.cfg.j2’})  
ERROR: change handler ({{ item.handler }}) is not defined

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 24, 2014, 9:45pm UTC](https://forum.ansible.com/t/notify-based-on-with-items-variable/16328/2 "2014-09-24T21:45:55Z")

</div>

Hi Paul,

The way notify works is if any of the tasks is changed (when looping) it will fire the notify.

It does not fire per task.

---

<div class="post-metadata">

**Author:** ![Paul\_Wolstenholme](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@Paul\_Wolstenholme](https://forum.ansible.com/u/Paul_Wolstenholme)\
**Post date:** [September 24, 2014, 10:51pm UTC](https://forum.ansible.com/t/notify-based-on-with-items-variable/16328/3 "2014-09-24T22:51:10Z")

</div>

Hi Michael,

Thanks for clarifying that for me.

Cheers,  
Paul
