with_items and template using {{item}}

Hi all,

I’m fancing with the following problem. Imagine, you have following tak

- name: template everything for fooserv
   template: src={{item.0}} dest={{item.1}}
   with_items:
      - [ 'templates/foo.j2', '/etc/splat/foo.conf' ]
      - [ 'templates/bar.j2', '/etc/splat/bar.conf’ ]

Or

- name: template everything for fooserv
   template: src={{item.src}} dest={{item.dest}}
   with_items:
   - { src: 'templates/foo.j2', b: '/etc/splat/foo.conf' }
   - { src: 'templates/bar.j2', b: '/etc/splat/bar.conf' }

The question is, is there a way how to access the {{ item }} in template
file ?

  Thanks,
    Peter

Try it? :slight_smile:

Yes, in just the same way as you noted it in the action line.​