0
votes

Within the Ansible Tower/AWX gui I have created an inventory with a source to poll my VMWare vCenter instance for hosts. The documentation I referenced does not include examples that filter hosts. I am trying to only import CentOS or RHEL systems from VMware into Tower/AWX.

I have tried this string and it does not filter the correct hosts.

{{ config.guestId == "centos*" or config.guestId == "RHEL*" }}

This Tower documentation on VMWare sourced inventory does not include examples. https://docs.ansible.com/ansible-tower/latest/html/userguide/inventories.html?extIdCarryOver=true&sc_cid=701f2000001OH6kAAG#vmware-vcenter

This VMware documentation on quick filters also does not offer an example. https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.vcenterhost.doc/GUID-2B6A1637-384D-4597-B453-B575F0ECD8A7.html

1

1 Answers

0
votes

This string will filter for only CentOS or RHEL systems in a VMware sourced inventory.

{{ config['guestId'] is search("centos*") or config['guestId'] is search("rhel*") }}

I used the documentation around testing strings here. I also was trying to index the element in the config array incorrectly.

https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html#testing-strings