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

-- 
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/de933ec7-bc71-4e56-b3db-55cf85a43409%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to