# Inventory updates not appearing after provisioning ec2 instance

**URL:** <https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882>\
**Category:** Ansible Project\
**Created:** [August 7, 2014, 2:02am UTC](https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882 "2014-08-07T02:02:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Ringo](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@Steven\_Ringo](https://forum.ansible.com/u/Steven_Ringo)\
**Post date:** [August 7, 2014, 2:02am UTC](https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882/1 "2014-08-07T02:02:03Z")

</div>

Hi,

After provisioning a machine on ec2 module, the inventory doesn’t reflect the new host (using ec2.py).

I am using a tag\_name for the target host that comes from the inventory.

I have tried all of the following:

- pause of 60 seconds after provisioning.

- local\_action to refresh the cache, calling ec2.py --refresh-cache

- changing the cache\_max\_age timeout to 0 in ec2.ini

The other thing I tried was to use not use the inventory script, but to use add\_host with the same group name as my tag name. This seems hacky though and seems also not read the group\_vars, which is a problem.

If anyone has any ideas, that would be great.

Thanks,

Steve

---

<div class="post-metadata">

**Author:** ![Steven\_Ringo](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@Steven\_Ringo](https://forum.ansible.com/u/Steven_Ringo)\
**Post date:** [August 7, 2014, 2:30am UTC](https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882/2 "2014-08-07T02:30:39Z")

</div>

Having a look at the inventory file immediately after the machine is provisioned, it does in fact update correctly.

However it appears that the inventory file is run/read only once at the beginning of a playbook, so it will not reflect the new host if the deploy playbook is run by including it after the provisioning playbook.

Looks like I will need to use add\_host then, or find a way to get Ansible to refresh the inventory in the middle of a play.

---

<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:** [August 7, 2014, 1:59pm UTC](https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882/3 "2014-08-07T13:59:40Z")

</div>

add\_host is the correct approach.

---

<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:** [August 7, 2014, 9:32pm UTC](https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882/4 "2014-08-07T21:32:16Z")

</div>

Correct - inventory files are not re-consulted in the middle of a playbook run.

---

<div class="post-metadata">

**Author:** ![Steven\_Ringo](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@Steven\_Ringo](https://forum.ansible.com/u/Steven_Ringo)\
**Post date:** [August 7, 2014, 9:35pm UTC](https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882/5 "2014-08-07T21:35:55Z")

</div>

Thanks Michael and and Matt.

I have noticed that the group\_vars for a group added in add\_host are (seemingly) not picked up. Is this correct behaviour?

---

<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:** [August 7, 2014, 9:41pm UTC](https://forum.ansible.com/t/inventory-updates-not-appearing-after-provisioning-ec2-instance/15882/6 "2014-08-07T21:41:36Z")

</div>

If you added it to a group they should be picked up.

If seeing this in Ansible 1.7, please do file a bug.

If you need a workaround, you could:

- include\_vars: group\_vars\_path/groupname\_here

At the top of play that targets groupname, but that should not be needed.
