# template with\_items fails with more than one item

**URL:** <https://forum.ansible.com/t/template-with-items-fails-with-more-than-one-item/14509>\
**Category:** Ansible Project\
**Created:** [February 6, 2014, 2:44pm UTC](https://forum.ansible.com/t/template-with-items-fails-with-more-than-one-item/14509 "2014-02-06T14:44:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jepper](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jepper](https://forum.ansible.com/u/jepper)\
**Post date:** [February 6, 2014, 2:44pm UTC](https://forum.ansible.com/t/template-with-items-fails-with-more-than-one-item/14509/1 "2014-02-06T14:44:17Z")

</div>

I am using templates and with\_items to loop over a directory of templates. When I do just one item, in my list it works. With 2 lines it fails:

Works:

- name: replace variables in templates  
template: src={{item}}.j2 dest={{ mule }}/{{item}}  
with\_items:

# trp-adapter.xml

trp.properties  
ok: [root-build] =\> (item=trp.properties) =\> {“changed”: false, etc.

Works:

- name: replace variables in templates  
template: src={{item}}.j2 dest={{ mule }}/{{item}}  
with\_items:  
trp-adapter.xml

# trp.properties

ok: [root-build] =\> (item=trp-adapter.xml) =\> {“changed”: false, etc.

Fails:

- name: replace variables in templates  
template: src={{item}}.j2 dest={{ mule }}/{{item}}  
with\_items:  
trp-adapter.xml  
trp.properties

fatal: [root-build] =\> input file not found at /home/ansible/svn/playbooks/rolebased/roles/esb/templates/trp-adapter.xml or /home/ansible/svn/playbooks/rolebased/trp-adapter.xml

Ansible is not looking for the .j2 file in the third example:  
$ ls /home/ansible/svn/playbooks/rolebased/roles/esb/templates  
trp-adapter.xml.j2

Bug? Can I do this a better way?

---

<div class="post-metadata">

**Author:** ![jepper](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jepper](https://forum.ansible.com/u/jepper)\
**Post date:** [February 6, 2014, 3:00pm UTC](https://forum.ansible.com/t/template-with-items-fails-with-more-than-one-item/14509/2 "2014-02-06T15:00:01Z")

</div>

I spotted the problem…! Missing dash:

- trp-adapter.xml
- trp.properties
