# Inventory conversion from static to ec2

**URL:** <https://forum.ansible.com/t/inventory-conversion-from-static-to-ec2/29382>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [January 6, 2019, 10:46pm UTC](https://forum.ansible.com/t/inventory-conversion-from-static-to-ec2/29382 "2019-01-06T22:46:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karthick\_Thanigaiman](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@Karthick\_Thanigaiman](https://forum.ansible.com/u/Karthick_Thanigaiman)\
**Post date:** [January 6, 2019, 10:46pm UTC](https://forum.ansible.com/t/inventory-conversion-from-static-to-ec2/29382/1 "2019-01-06T22:46:39Z")

</div>

Hi,

We currently have our inventory as like below in the on-prem and we would like to convert this to an understandable format for Ec2 instances in the AWS cloud infrastructure.  
the inventory is being referred using :  
inventory: ‘repo/inventory/dyn’,

e.g.  
HOSTNAME1:

dataip: IP1  
environment\_id: development

role: [componentname]

HOSTNAME2:

dataip: IP2  
environment\_id: development

role: [component2]

Can someone help or guide on how to convert this to a ec2.py format so that when the code deployment happens via the jenkins, it can be done without much changes in the ansible code?

Thank you

Regards  
Karthick

---

<div class="post-metadata">

**Author:** ![Karthick\_Thanigaiman](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@Karthick\_Thanigaiman](https://forum.ansible.com/u/Karthick_Thanigaiman)\
**Post date:** [January 7, 2019, 8:34pm UTC](https://forum.ansible.com/t/inventory-conversion-from-static-to-ec2/29382/2 "2019-01-07T20:34:05Z")

</div>

Hi,

can someone help on this please.

Thank you

---

<div class="post-metadata">

**Author:** ![jegansignup](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@jegansignup](https://forum.ansible.com/u/jegansignup)\
**Post date:** [January 8, 2019, 4:01am UTC](https://forum.ansible.com/t/inventory-conversion-from-static-to-ec2/29382/3 "2019-01-08T04:01:53Z")

</div>

Do you want to write dynamic inventory script for you inventory.

Does the inventory look as like as below which you have shared else provide exact inventory sample.

---

<div class="post-metadata">

**Author:** ![Karthick\_Thanigaiman](https://avatars.discourse-cdn.com/v4/letter/k/aca169/32.png) [@Karthick\_Thanigaiman](https://forum.ansible.com/u/Karthick_Thanigaiman)\
**Post date:** [January 8, 2019, 5:08am UTC](https://forum.ansible.com/t/inventory-conversion-from-static-to-ec2/29382/4 "2019-01-08T05:08:01Z")

</div>

Hi,

yes, it does like the below that I have shared. from the current code of ansible playbook it is given like below for the execution but this doesnt work for the EC2 / AWS instances.

ansiblePlaybook(  
playbook: ‘web.yml’,  
inventory: ‘config/inventory/dyn’,  
credentialsId: “deploy”,  
sudo: true,  
sudoUser: “root”,  
limit: limit,  
colorized: true,  
extras: extraParams

)
