# How to use variable template in shell or command

**URL:** <https://forum.ansible.com/t/how-to-use-variable-template-in-shell-or-command/16819>\
**Category:** Ansible Project\
**Created:** [November 19, 2014, 6:47am UTC](https://forum.ansible.com/t/how-to-use-variable-template-in-shell-or-command/16819 "2014-11-19T06:47:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [November 19, 2014, 6:47am UTC](https://forum.ansible.com/t/how-to-use-variable-template-in-shell-or-command/16819/1 "2014-11-19T06:47:50Z")

</div>

Hi everyone,

I want to something like this

- name: Run the setup script  
shell: “{{ SITE\_DIR }}”/setup\_jibs.sh creates=“{{ item }}/run\_setup\_jibs\_DO\_NOT\_REMOVE.sh”

and yaml complain as it is not valid

The first after the shell: must be a value that is why. If I put something

- name: Run the setup script  
shell: cmd=“{{ SITE\_DIR }}”/setup\_jibs.sh creates=“{{ item }}/run\_setup\_jibs\_DO\_NOT\_REMOVE.sh”

then yaml will be OK (noted the cmd= ; But i guess it wont work - shell does not have that attributes cmd and takes that as a string for teh shell to execute.

How can I get that done?

Similar to the command module as well

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_Peters](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@Michael\_Peters](https://forum.ansible.com/u/Michael_Peters)\
**Post date:** [November 19, 2014, 2:48pm UTC](https://forum.ansible.com/t/how-to-use-variable-template-in-shell-or-command/16819/2 "2014-11-19T14:48:44Z")

</div>

Instead of quoting each individual value, quote the whole line like this:

- name: Run the setup script  
&nbsp;&nbsp;shell: "{{ SITE\_DIR }}/setup\_jibs.sh creates={{ item  
}}/run\_setup\_jibs\_DO\_NOT\_REMOVE.sh"

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [November 20, 2014, 12:00am UTC](https://forum.ansible.com/t/how-to-use-variable-template-in-shell-or-command/16819/3 "2014-11-20T00:00:16Z")

</div>

Thanks will try.

Kind regards
