Inventory updates not appearing after provisioning ec2 instance

203 views
Skip to first unread message

Steven Ringo

unread,
Aug 6, 2014, 10:02:03 PM8/6/14
to ansible...@googlegroups.com
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

Steven Ringo

unread,
Aug 6, 2014, 10:30:50 PM8/6/14
to ansible...@googlegroups.com
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.


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/yWo3VGmNQH4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/f3fb161f-79f2-4b7f-b110-3e05c43c4f43%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matt Martz

unread,
Aug 7, 2014, 9:59:47 AM8/7/14
to ansible...@googlegroups.com
add_host is the correct approach.
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
ma...@sivel.net
http://sivel.net/

Michael DeHaan

unread,
Aug 7, 2014, 5:32:22 PM8/7/14
to ansible...@googlegroups.com
Correct -  inventory files are not re-consulted in the middle of a playbook run.




Steven Ringo

unread,
Aug 7, 2014, 5:36:09 PM8/7/14
to ansible...@googlegroups.com
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?


Michael DeHaan

unread,
Aug 7, 2014, 5:41:43 PM8/7/14
to ansible...@googlegroups.com
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.





Reply all
Reply to author
Forward
0 new messages