# create inventory hosts file from ec2 module

**URL:** <https://forum.ansible.com/t/create-inventory-hosts-file-from-ec2-module/14196>\
**Category:** Ansible Project\
**Created:** [December 20, 2013, 2:45pm UTC](https://forum.ansible.com/t/create-inventory-hosts-file-from-ec2-module/14196 "2013-12-20T14:45:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yves\_Dorfsman](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@Yves\_Dorfsman](https://forum.ansible.com/u/Yves_Dorfsman)\
**Post date:** [December 20, 2013, 2:45pm UTC](https://forum.ansible.com/t/create-inventory-hosts-file-from-ec2-module/14196/1 "2013-12-20T14:45:22Z")

</div>

Is there a way to change the inventory hosts file (on disk) from the ec2 module, when it launching new instances?

Thanks.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [December 20, 2013, 3:40pm UTC](https://forum.ansible.com/t/create-inventory-hosts-file-from-ec2-module/14196/2 "2013-12-20T15:40:16Z")

</div>

Have you instead looked at the ec2.py inventory script?

This would negate the need for manipulating a static file. And would really be the recommended way of handling this.

However I imagine you might be able to use the ini\_file module with local\_action to manipulate a local inventory file.
