# vmware\_vm\_facts - limit to set of matched names

**URL:** <https://forum.ansible.com/t/vmware-vm-facts-limit-to-set-of-matched-names/30495>\
**Category:** Ansible Project\
**Created:** [June 5, 2019, 2:05pm UTC](https://forum.ansible.com/t/vmware-vm-facts-limit-to-set-of-matched-names/30495 "2019-06-05T14:05:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gforster](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/gforster/32/535_2.png) [@gforster](https://forum.ansible.com/u/gforster)\
**Post date:** [June 5, 2019, 2:05pm UTC](https://forum.ansible.com/t/vmware-vm-facts-limit-to-set-of-matched-names/30495/1 "2019-06-05T14:05:42Z")

</div>

Is it possible to limit the vmware\_vm\_facts module to only return a subset of regex-matched vms?

Big picture: I have a hostname standard that, in part, goes by a sequence # e.g. something-app-prod3a (where 3 is the sequence number). To ensure that all hostnames are unique, I need to check what the highest sequence number is. If there is no match, start at 1, otherwise it is existing\_name + 1. So, I need to check for anything leading up to the number for a match, strip off the last letter, get that number and do stuff with it.

Maybe there is a better way to accomplish what I need? I can get a list of all vms with vmware\_vm\_facts, but that takes a loooong time (nearly 6 minutes) and doesn’t seem to be necessary. Potentially the right answer is to do this in a separate script, but would rather keep everything ansible-native if possible.
