# EC2 provisionning and configuring with variables from inventory/ec2.py

**URL:** <https://forum.ansible.com/t/ec2-provisionning-and-configuring-with-variables-from-inventory-ec2-py/16683>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [November 4, 2014, 8:56am UTC](https://forum.ansible.com/t/ec2-provisionning-and-configuring-with-variables-from-inventory-ec2-py/16683 "2014-11-04T08:56:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olivier\_Vernin](https://avatars.discourse-cdn.com/v4/letter/o/6bbea6/32.png) [@Olivier\_Vernin](https://forum.ansible.com/u/Olivier_Vernin)\
**Post date:** [November 4, 2014, 8:56am UTC](https://forum.ansible.com/t/ec2-provisionning-and-configuring-with-variables-from-inventory-ec2-py/16683/1 "2014-11-04T08:56:14Z")

</div>

Hi,  
I am facing a little problem and I don’t find a clear solution  
I need to provision a new EC2 (AWS) instance and configure it.  
During the configuration I use some variables from the inventory script ec2.py

So I tried two approaches:

1. I executed two different playbooks under a shell script  
¦ - ansible-playbook create\_ec2.yml  
¦ - ansible-playbook configure\_ec2.yml

¦ This approach works but I use a shell script which execute two ansible scripts

1. I execute a meta playbook (which include create\_ec2.yml then configure\_ec2.yml)  
¦ - ansible-playbook meta\_ec2.yml

¦ This approach fail because it doesn’t know variable like ec2\_private\_ip\_address from ec2.py  
¦ So I tried different thinks to get those variables, add  
¦ ¦ ‘’’ - name: Refresh AWS Cache  
¦ ¦ ¦ - command: inventory.d/ec2.py --refresh-cache  
¦ ¦ ‘’’  
¦ ¦ ¦ - name: gathering ec2 facts  
¦ ¦ ¦ ¦ ec2\_facts:  
¦ ¦ ‘’’  
¦ But none of them work  
Is anyone has an advice?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [November 5, 2014, 2:23pm UTC](https://forum.ansible.com/t/ec2-provisionning-and-configuring-with-variables-from-inventory-ec2-py/16683/2 "2014-11-05T14:23:44Z")

</div>

Typically the create playbook would include the configure playbook, using the “add\_host” trick.

This is covered a bit in EC2 examples, others here can also offer some good pointers to EC2 workflow.

We’re going to working on making the EC2 “best practices” type doc stuff a lot better in the coming months to show how to string these things together.
