I want to create dynamic inventory with the vmware.vmware.vms ansible plugin. I want to customize my inventory to select Linux hosts only.
I don't understand how the plugin is working and the ansible documentation is poor on examples and explanations (https://docs.ansible.com/ansible/latest/collections/vmware/vmware/vms_inventory.html#ansible-collections-vmware-vmware-vms-inventory)
With the code below the plugin is returning me 3 groups (linux, PoweredOn, PoweredOff). Under the created "linux" group all the hosts from the vmware are returned (even Windows based). And the plugin keeps returning me a long output anyway with unwanted values even if I tell him to group using the "guest.guestFamily" property.
plugin: vmware.vmware.vms
hostname: "REDACTED"
username: "REDACTED"
password: "REDACTED"
validate_certs: false
properties: ["guest"]
groups:
linux: guest.guestFamily
My goals are :
- how can I use the plugin to filter specific hosts and add them to a group
- how to avoid outputing unwanted groups (like PoweredOn and PoweredOff default group)
- how can I output the return of the pluging to a usable .yaml/.ini format or file (ready to be used with a playbook)