Chethan S.
Chethan S.

Reputation: 556

Excluding specific VMs from Ansible Inventory: VMware

I have configured a group with source "VMware vCenter" in Ansible Tower. As per the documentation, one can specify Source Variables to

Override variables found in vmware.ini and used by the inventory update script. For a detailed description of these variables view vmware.ini in the Ansible github repo.

An excerpt from the GitHub file -

Specify a prefix filter. Any VMs with names beginning with this string will not be returned. 
prefix_filter = test_ 

In my case, I have at least three prefixes that need to be excluded. However, when I try to do that by specifying prefix_filter three times, only first one seems to work. How can I exclude VMs which start with names other than Te?

enter image description here

Upvotes: 0

Views: 1890

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68269

Answer from my comment:

I'd try to use newer inventory script vmware_inventory.py with jinja host_filters or to patch vmware.py if vm.name.startswith( prefix_filter ) to something that suits your needs.

Upvotes: 2

Related Questions