template with_items fails with more than one item

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?

I spotted the problem…! Missing dash:

  • trp-adapter.xml
  • trp.properties