# Get List of Inventory Hosts that Match a patter

**URL:** <https://forum.ansible.com/t/get-list-of-inventory-hosts-that-match-a-patter/21804>\
**Category:** Ansible Project\
**Created:** [June 17, 2016, 11:46pm UTC](https://forum.ansible.com/t/get-list-of-inventory-hosts-that-match-a-patter/21804 "2016-06-17T23:46:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joaquin\_Menchaca](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Joaquin\_Menchaca](https://forum.ansible.com/u/Joaquin_Menchaca)\
**Post date:** [June 17, 2016, 11:46pm UTC](https://forum.ansible.com/t/get-list-of-inventory-hosts-that-match-a-patter/21804/1 "2016-06-17T23:46:23Z")

</div>

How can I enumerate all the host names in the inventory that match a particular pattern? For example, I would like to grab all the supervisors from this set. I want to use this list to configure something in a configuration file.

My dynamic inventory would return something like like this:

{

“vagrant”: [

“nimbus”,

“supervisor1”,

“supervisor2”,

“zookeeper”

],

“\_meta”: {

“hostvars”: {

“nimbus”: {

“ansible\_ssh\_host”: “192.168.54.4”,

“ansible\_ssh\_user”: “vagrant”,

“ansible\_ssh\_private\_key\_file”: “.vagrant/machines/nimbus/virtualbox/private\_key”

},

“supervisor1”: {

“ansible\_ssh\_host”: “192.168.54.5”,

“ansible\_ssh\_user”: “vagrant”,

“ansible\_ssh\_private\_key\_file”: “.vagrant/machines/supervisor1/virtualbox/private\_key”

},

“supervisor2”: {

“ansible\_ssh\_host”: “192.168.54.6”,

“ansible\_ssh\_user”: “vagrant”,

“ansible\_ssh\_private\_key\_file”: “.vagrant/machines/supervisor2/virtualbox/private\_key”

},

“zookeeper”: {

“ansible\_ssh\_host”: “192.168.54.3”,

“ansible\_ssh\_user”: “vagrant”,

“ansible\_ssh\_private\_key\_file”: “.vagrant/machines/zookeeper/virtualbox/private\_key”

}

}

}

}
