0

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

Chethan S.
  • 558
  • 2
  • 8
  • 28
  • I'm not an expert with Tower, but with bare Ansible I'd try to use newer inventory script [vmware_inventory.py](https://github.com/ansible/ansible/blob/devel/contrib/inventory/vmware_inventory.py) with jinja `host_filters` or to patch vmware.py `if vm.name.startswith( prefix_filter )` to something that suits your needs. – Konstantin Suvorov Jul 11 '16 at 18:55
  • I am trying to tweak the vmware.py to suit my needs. It is said that it relies on vmware.ini file but I don't see that ini file anywhere. Do you have any idea of which would be the right place to create one such file? Even vmware_inventory.py can rely on an ini file but there's no mention of where to find / create one. – Chethan S. Jul 12 '16 at 06:42
  • First `VMWARE_INI` env var is checked for path, then it looks in the same directory as vmware.py – Konstantin Suvorov Jul 12 '16 at 07:36
  • @KonstantinSuvorov, we managed to tweak the prefix_filter in vmware.py to exclude the VMs. If you could post your first comment as an answer, I will accept it. We no longer use a ini file. – Chethan S. Jul 12 '16 at 09:21
  • 1
    Cool, glad that it helped. – Konstantin Suvorov Jul 12 '16 at 09:28

1 Answers1

2

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.

Konstantin Suvorov
  • 65,183
  • 9
  • 162
  • 193