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

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

Hello,

for passing parameters to the script please see the first example on
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

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