How configure Tower Template to use Dynamic Inventory Script.

Hello Ansible Team,

I have written a Python script “inv-sched.py” which generates a JSON format inventory. This script is working using the command line ansible, with ansible command and ansible-playbook.
Now I want to use this script through Tower manager, how can I configure a Template to use it ?.

Thank you for help.

Best regards.

Flavio Gobber

you can create a custom inventory script https://docs.ansible.com/ansible-tower/latest/html/administration/custom_inventory_script.html

well, I have added my script to “Inventory Script”, but now, how can I use this script/Inventory in may “Template” for schedule a Playbook ?.
Thank you

Flavio Gobber

dis you create an inventory and added a source that that gets the hosts? then on your job template there’s an inventory option to pick.

Jonathan Lozada De La Matta on mobile

– You received this message because you are subscribed to the Google Groups “Ansible Project” group. To unsubscribe from this group and stop receiving emails from it, send an email to . To post to this group, send email to . To view this discussion on the web visit . For more options, visit .

Hello Jonathan,

I would show you with two screenshot what I have done and what I see on template page.

The Inventory selection on Template configuration doesn’t show me to choose the script previus defined.

With the script showed above and ansible CLI the inventory works well.

Thank you

Beest regards

Flavio Gobber

after you add the inventory script, you need to create an inventory. Once you create an inventory, you need to create a source. Please look at the documentation.

Jonathan Lozada De La Matta on mobile

– You received this message because you are subscribed to the Google Groups “Ansible Project” group. To unsubscribe from this group and stop receiving emails from it, send an email to . To post to this group, send email to . To view this discussion on the web visit . For more options, visit .

(attachments)


Hello Jonathan,

thank you for help, now I am able to use a Python script to create an inventory. Now I am not able to use a custom Python class inside the script. I have write a python class “class ScheduleInventory” into a file .py, this class receive in input two parameter. Then into Tower I have write this script:

#!/usr/bin/env python

from sched_inv import ScheduleInventory
ScheduleInventory(“schedwu.ini”,“Download & Install Update & Reboot - 2o gruppo”)

If I run this script it works well, but not in Tower, I think the origin is because the class is not in the right python lib folder, where i need to put the “class ScheduleInventory” into a file .py ?.

Thank you for help.

Best regards.

Flavio Gobber

en into the