# Use inventory script to get dynamic inventory at job runtime ?

**URL:** <https://forum.ansible.com/t/use-inventory-script-to-get-dynamic-inventory-at-job-runtime/29571>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [January 30, 2019, 3:24pm UTC](https://forum.ansible.com/t/use-inventory-script-to-get-dynamic-inventory-at-job-runtime/29571 "2019-01-30T15:24:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Francois\_van\_Ae](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@Jean-Francois\_van\_Ae](https://forum.ansible.com/u/Jean-Francois_van_Ae)\
**Post date:** [January 30, 2019, 3:24pm UTC](https://forum.ansible.com/t/use-inventory-script-to-get-dynamic-inventory-at-job-runtime/29571/1 "2019-01-30T15:24:18Z")

</div>

Hello,

I would like to run one template to be able to install mutliple similar applications with different components in different environments.  
for exemple:

- application1 has a batch and a web module that runs on 2 differents hosts in each environment (dev/tst/acc/prd)
- application2 also has a batch and a web module that runs on 4 different hosts in each environment (dev/tst/acc/prd)

I’ve created a job template in AWX that request 2 extra\_vars to install any application: app\_name & env.  
the job calls a playbook that will take action on batch and other actions on web servers.

I would find very convenient to use a dynamic inventory directly in the template so that at job runtime it would call my inventory script with the 2 args (app + env)  
it would then return a very basic json with my

{  
“batch”: [  
“server1.domain”  
],  
“web”: [  
“server2.domain”  
]  
}

Or do you see any other mechanism to be able to run the same template to do so ?  
if you need more info, don’t hesitate.

Brgds

JF
