# tower ansible template: how to pass parameters to a python script

**URL:** <https://forum.ansible.com/t/tower-ansible-template-how-to-pass-parameters-to-a-python-script/30520>\
**Category:** Ansible Project\
**Created:** [June 10, 2019, 2:45pm UTC](https://forum.ansible.com/t/tower-ansible-template-how-to-pass-parameters-to-a-python-script/30520 "2019-06-10T14:45:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gilles](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Gilles](https://forum.ansible.com/u/Gilles)\
**Post date:** [June 10, 2019, 2:45pm UTC](https://forum.ansible.com/t/tower-ansible-template-how-to-pass-parameters-to-a-python-script/30520/1 "2019-06-10T14:45:21Z")

</div>

I am using a template to run a python script. This works fine.

> `
> 
> * * *
> 
> - hosts: ISE  
> connection: local  
> args:  
> tasks:
> - script: /usr/bin/python3 …/scripts/ise\_add.py  
> register: output
> - debug: var=output.stdout\_lines
> 
> `

Now I would like to pass 2 parameters to the python script (hostname and ipaddress), either harcoded or from any file or any variable.  
May I use the “extra variables” section of the template panel?  
Do I have to use Jinja2?

Thanks  
Regards,  
Gilles

---

<div class="post-metadata">

**Author:** ![Martin\_Krizek](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@Martin\_Krizek](https://forum.ansible.com/u/Martin_Krizek)\
**Post date:** [June 11, 2019, 7:03am UTC](https://forum.ansible.com/t/tower-ansible-template-how-to-pass-parameters-to-a-python-script/30520/2 "2019-06-11T07:03:36Z")

</div>

Hello,

for passing parameters to the script please see the first example on  
[https://docs.ansible.com/ansible/latest/modules/script\_module.html#examples](https://docs.ansible.com/ansible/latest/modules/script_module.html#examples).  
If you want to pass those parameters from variables then yes you need  
to use Jinja2.

Thanks,  
Martin

---

<div class="post-metadata">

**Author:** ![Gilles](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Gilles](https://forum.ansible.com/u/Gilles)\
**Post date:** [June 11, 2019, 7:28am UTC](https://forum.ansible.com/t/tower-ansible-template-how-to-pass-parameters-to-a-python-script/30520/3 "2019-06-11T07:28:23Z")

</div>

Hi Martin,

Thanks for the example. I would like to avoid to hardcode the parameters to be able to reuse the template. The idea was more to use variables.

I will have a look at the jinja2 side.

I may come back later if I don’t find what I am looking for.

Thanks

Gilles
