# sending vars to templates

**URL:** <https://forum.ansible.com/t/sending-vars-to-templates/12959>\
**Category:** Ansible Project\
**Created:** [June 13, 2013, 8:58pm UTC](https://forum.ansible.com/t/sending-vars-to-templates/12959 "2013-06-13T20:58:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arunoda\_Susiripala](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@Arunoda\_Susiripala](https://forum.ansible.com/u/Arunoda_Susiripala)\
**Post date:** [June 13, 2013, 8:58pm UTC](https://forum.ansible.com/t/sending-vars-to-templates/12959/1 "2013-06-13T20:58:13Z")

</div>

Hi,

I have a simple template and it uses some vars.  
now I need to send vars to it when invoking the actions

I’m planning to use the single template in few places, so I need send vars in each template action call? Is it possible?

I would expect something like below

**- name: git repo 1**  
**action: template src=templates/git-repo-init.sh.j2 dest=/tmp/git-repo-init-1.sh**  
**vars:**  
**app:sidebar**  
**[repo:"git@github.com](mailto:repo:%22git@github.com):arunoda/aa.git"**

**- name: git repo2**  
**action: template src=templates/git-repo-init.sh.j2 dest=/tmp/git-repo-init-2.sh**  
**vars:**  
**app:sidebar2**  
**[repo:"git@github.com](mailto:repo:%22git@github.com):arunoda/aa2.git"**

Thanks.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [June 14, 2013, 8:39pm UTC](https://forum.ansible.com/t/sending-vars-to-templates/12959/2 "2013-06-14T20:39:51Z")

</div>

you can do it liek this:

- name: git repo  
action: template src=templates/git-repo-init.sh.j2 dest=/tmp/git-repo-init-{{item.number}}.sh  
with\_items:
- number: 1  
app: sidebarrepo: “[git@github.com](mailto:git@github.com):arunoda/aa.git”
- number: 2  
app: sidebar2  
repo: “[git@github.com](mailto:git@github.com):arunoda/aa2.git”

in template you refer to the vars as item.app and item.repo
