# Reload inventory variables inside playbook execution

**URL:** <https://forum.ansible.com/t/reload-inventory-variables-inside-playbook-execution/18724>\
**Category:** Ansible Project\
**Created:** [July 9, 2015, 10:47pm UTC](https://forum.ansible.com/t/reload-inventory-variables-inside-playbook-execution/18724 "2015-07-09T22:47:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Galindro\_da\_Co](https://avatars.discourse-cdn.com/v4/letter/b/59ef9b/32.png) [@Bruno\_Galindro\_da\_Co](https://forum.ansible.com/u/Bruno_Galindro_da_Co)\
**Post date:** [July 9, 2015, 10:47pm UTC](https://forum.ansible.com/t/reload-inventory-variables-inside-playbook-execution/18724/1 "2015-07-09T22:47:28Z")

</div>

I need create an ec2 instance and execute many tasks on it. For accomplish this, I’ve build two playbooks: one for ec2 creation and other for configuration (package installation, application deploy, etc…). I’ve created a third playbook that calls booth using include statements. I’ve called it instance\_up.yml

`

---

<div class="post-metadata">

**Author:** ![igorc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/igorc/32/5491_2.png) [@igorc](https://forum.ansible.com/u/igorc)\
**Post date:** [July 11, 2015, 7:55am UTC](https://forum.ansible.com/t/reload-inventory-variables-inside-playbook-execution/18724/2 "2015-07-11T07:55:21Z")

</div>

May I ask why would you not go with the usual way of adding the newly created instance to a new host group and then configure it? As in the example from the ec2 page:

- name: Create a sandbox instance  
&nbsp;&nbsp;hosts: localhost  
&nbsp;&nbsp;gather\_facts: False  
&nbsp;&nbsp;vars:  
&nbsp;&nbsp;&nbsp;&nbsp;key\_name: my\_keypair  
&nbsp;&nbsp;&nbsp;&nbsp;instance\_type: m1.small  
&nbsp;&nbsp;&nbsp;&nbsp;security\_group: my\_securitygroup  
&nbsp;&nbsp;&nbsp;&nbsp;image: my\_ami\_id  
&nbsp;&nbsp;&nbsp;&nbsp;region: us-east-1  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- name: Launch instance  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ec2:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key\_name: "{{ keypair }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group: "{{ security\_group }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;instance\_type: "{{ instance\_type }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image: "{{ image }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wait: true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;region: "{{ region }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vpc\_subnet\_id: subnet-29e63245  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assign\_public\_ip: yes  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: ec2  
&nbsp;&nbsp;&nbsp;&nbsp;- name: Add new instance to host group  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add\_host: hostname={{ item.public\_ip }} groupname=launched  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items: ec2.instances  
&nbsp;&nbsp;&nbsp;&nbsp;- name: Wait for SSH to come up  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wait\_for: host={{ item.public\_dns\_name }} port=22 delay=60 timeout=320 state=started  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items: ec2.instances

- name: Configure instance(s)  
&nbsp;&nbsp;hosts: launched  
&nbsp;&nbsp;sudo: True  
&nbsp;&nbsp;gather\_facts: True  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;- include: config.yml  
&nbsp;&nbsp;&nbsp;&nbsp;- include: config2.yml  
&nbsp;&nbsp;&nbsp;&nbsp;....
