How configure Tower Template to use Dynamic Inventory Script.

59 views
Skip to first unread message

Flavio Gobber

unread,
May 23, 2019, 6:52:16 AM5/23/19
to Ansible Project
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

Jonathan Lozada De La Matta

unread,
May 23, 2019, 8:05:38 AM5/23/19
to ansible...@googlegroups.com

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ae5cff1b-acfb-4ecc-9d82-eb830aa9d3e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Automation Practice

Senior Automation Consultant & Automation CoP Manager

Red Hat


 

Flavio Gobber

unread,
May 23, 2019, 8:19:36 AM5/23/19
to Ansible Project
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

On Thursday, May 23, 2019 at 2:05:38 PM UTC+2, Jonathan Lozada De La Matta wrote:
On Thu, May 23, 2019 at 6:52 AM Flavio Gobber <fgo...@gmail.com> wrote:
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 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 ansible...@googlegroups.com.

Jonathan Lozada De La Matta

unread,
May 23, 2019, 8:50:28 AM5/23/19
to ansible...@googlegroups.com
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
 

From: ansible...@googlegroups.com on behalf of Flavio Gobber <fgo...@gmail.com>
Sent: Thursday, May 23, 2019 8:19 AM
To: Ansible Project
Subject: Re: [ansible-project] How configure Tower Template to use Dynamic Inventory Script.
 
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

Flavio Gobber

unread,
May 24, 2019, 4:34:57 AM5/24/19
to Ansible Project
Hello Jonathan,

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

InventoryScreenCapture.PNG

SelectInventoryScreenCapture.PNG


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

Jonathan Lozada De La Matta

unread,
May 24, 2019, 6:31:43 AM5/24/19
to ansible...@googlegroups.com
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
From: ansible...@googlegroups.com on behalf of Flavio Gobber <fgo...@gmail.com>
Sent: Friday, May 24, 2019 4:35 AM
To: Ansible Project
Subject: [ansible-project] Re: How configure Tower Template to use Dynamic Inventory Script.
 
--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Flavio Gobber

unread,
Jun 4, 2019, 6:09:39 AM6/4/19
to Ansible Project
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

On Thursday, May 23, 2019 at 12:52:16 PM UTC+2, Flavio Gobber wrote:
Reply all
Reply to author
Forward
0 new messages