# Can we Run Command in Jinja2 Template

**URL:** <https://forum.ansible.com/t/can-we-run-command-in-jinja2-template/30749>\
**Category:** Ansible Project\
**Created:** [July 10, 2019, 8:35pm UTC](https://forum.ansible.com/t/can-we-run-command-in-jinja2-template/30749 "2019-07-10T20:35:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bishwajit\_Samanta](https://avatars.discourse-cdn.com/v4/letter/b/8e7dd6/32.png) [@Bishwajit\_Samanta](https://forum.ansible.com/u/Bishwajit_Samanta)\
**Post date:** [July 10, 2019, 8:35pm UTC](https://forum.ansible.com/t/can-we-run-command-in-jinja2-template/30749/1 "2019-07-10T20:35:48Z")

</div>

Hi Team,

I was curious can we run command in jinja2 template say example

{{pwd}} === here pwd is a shell command.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 10, 2019, 8:47pm UTC](https://forum.ansible.com/t/can-we-run-command-in-jinja2-template/30749/2 "2019-07-10T20:47:22Z")

</div>

Template only run on localhost aka Ansible controller.  
So if the command you wanna run is against localhost you can use lookup plugin with pipe  
[https://docs.ansible.com/ansible/latest/plugins/lookup/pipe.html](https://docs.ansible.com/ansible/latest/plugins/lookup/pipe.html)
