How to refresh Ansible Dynamic Inventory (vCenter Server)?

618 views
Skip to first unread message

Chethan S

unread,
Sep 2, 2016, 4:15:08 AM9/2/16
to Ansible Project
We are building an Ansible playbook which takes care of creating VMs in VMware vCenter and is later expected to perform some operations inside the newly created VMs. While the creation of VMs is successful, there seems to be no way to refresh the dynamic VMware inventory mid-play. Web searches took me to several Amazon EC2 related results where they pointed to the usage of 

- meta: refresh_inventory

which is supposed to do that. However, this approach does not seem to work for vCenter inventories. Can you suggest me an approach to handle this?



Erick Barros

unread,
Sep 23, 2016, 11:29:55 AM9/23/16
to Ansible Project
Hey Chetan,

Did you have any success on that?

Brian Coca

unread,
Sep 23, 2016, 11:37:17 AM9/23/16
to ansible...@googlegroups.com
`meta: refresh_inventory ` can only re-execute the inventory script, if the script is using a cache, Ansible cannot know this and has no way of telling it not to.


----------
Brian Coca

Chethan S

unread,
Sep 23, 2016, 11:53:00 AM9/23/16
to Ansible Project
@Erick, no, there was no success on this.

@Brian, when we use Ansible Tower and dynamic inventories, cache comes into the picture. A manual inventory refresh on the tower GUI or the automated one just before playbook is run, occurs based on the cache timeout values. 

Reportedly, users of EC2 inventory scripts are able to use this functionality without any issues.

Brian Coca

unread,
Sep 23, 2016, 12:00:36 PM9/23/16
to ansible...@googlegroups.com
I am aware of the issues with Tower and script caches, those ec2 users must not be using the cache the script supports.


----------
Brian Coca

Chethan S

unread,
Sep 23, 2016, 12:09:08 PM9/23/16
to Ansible Project
Thanks, Brian for confirming that. I had tried filing a bug for the same but it was closed almost immediately - https://github.com/ansible/ansible/issues/17409. Ansible Tower support didn't help much either. Is there any chance of a fix for this?

Brian Coca

unread,
Sep 23, 2016, 12:14:20 PM9/23/16
to ansible...@googlegroups.com
We are looking at a couple of approaches.

One would require inventory scripts to standardize how they cache and how to avoid caches.

The other is part of the pending inventory rewrite (we did not fit it into 2.0 and it requires a big revamp), moving most inventory scripts into actual plugins and having an 'inventory cache' available that Ansible controls.

​Since we'll be keeping the current scripts.py as a plugin and backwards compatibility with the existing scripts, both might be needed.​


----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages