vmware_inventory group_by

25 views
Skip to first unread message

Karen Tovmasian

unread,
Dec 19, 2016, 3:17:19 PM12/19/16
to Ansible Project
Hi all.

I'm investigatin the dynamic inventory script "vmware_inventory.py (this one https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware_inventory.py)
I'd like to know how can i use _meta vars or other facts to use group_by to apply a role or run some action on it.
In _meta it looks like this

"_meta": {
    "hostvars": {
      "server": {
        "resourcepool": {
          "_moId": "resgroup-13971", 
          "name": "myresourcepool"
        }, 

for instance
---
- name: test
  tasks
:
 
- name: group the servers
    group_by
: key = _meta.hostvars.*(or something to pick all the hosts).resourcepool.myresourcepool

I'm new to JSON and dynamic inventory so if you have a better idea this would be welcome.
The example with resource pool is just an example - i'd like to have ability to create ad hoc group based on other machine settings.



Reply all
Reply to author
Forward
0 new messages