# with\_items and template using {{item}}

**URL:** <https://forum.ansible.com/t/with-items-and-template-using-item/13937>\
**Category:** Ansible Project\
**Created:** [November 19, 2013, 7:44pm UTC](https://forum.ansible.com/t/with-items-and-template-using-item/13937 "2013-11-19T19:44:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hudec\_Peter](https://avatars.discourse-cdn.com/v4/letter/h/a87d85/32.png) [@Hudec\_Peter](https://forum.ansible.com/u/Hudec_Peter)\
**Post date:** [November 19, 2013, 7:44pm UTC](https://forum.ansible.com/t/with-items-and-template-using-item/13937/1 "2013-11-19T19:44:03Z")

</div>

Hi all,

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

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

Or

- name: template everything for fooserv  
&nbsp;&nbsp;&nbsp;template: src={{item.src}} dest={{item.dest}}  
&nbsp;&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;- { src: 'templates/foo.j2', b: '/etc/splat/foo.conf' }  
&nbsp;&nbsp;&nbsp;- { src: 'templates/bar.j2', b: '/etc/splat/bar.conf' }

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

&nbsp;&nbsp;Thanks,  
&nbsp;&nbsp;&nbsp;&nbsp;Peter

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 19, 2013, 7:55pm UTC](https://forum.ansible.com/t/with-items-and-template-using-item/13937/2 "2013-11-19T19:55:54Z")

</div>

Try it? 🙂

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [November 19, 2013, 7:56pm UTC](https://forum.ansible.com/t/with-items-and-template-using-item/13937/3 "2013-11-19T19:56:45Z")

</div>

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