# Filter inventory list based on facts

**URL:** <https://forum.ansible.com/t/filter-inventory-list-based-on-facts/13846>\
**Category:** Ansible Project\
**Created:** [November 5, 2013, 6:24am UTC](https://forum.ansible.com/t/filter-inventory-list-based-on-facts/13846 "2013-11-05T06:24:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gonzalo\_Servat](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Gonzalo\_Servat](https://forum.ansible.com/u/Gonzalo_Servat)\
**Post date:** [November 5, 2013, 6:24am UTC](https://forum.ansible.com/t/filter-inventory-list-based-on-facts/13846/1 "2013-11-05T06:24:36Z")

</div>

Hi,

Another question: is it possible to filter an inventory listing based on facts?

For example: having the ability to run a playbook or some custom command on all hosts where ansible\_facts.facter\_operatingsystemrelease \>= 11.

Thanks  
Gonzalo

---

<div class="post-metadata">

**Author:** ![Jim\_Richardson](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jim\_Richardson](https://forum.ansible.com/u/Jim_Richardson)\
**Post date:** [November 5, 2013, 3:43pm UTC](https://forum.ansible.com/t/filter-inventory-list-based-on-facts/13846/2 "2013-11-05T15:43:03Z")

</div>

You can use group\_by for that. Examples should be in the examples Dir.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [November 6, 2013, 2:07pm UTC](https://forum.ansible.com/t/filter-inventory-list-based-on-facts/13846/3 "2013-11-06T14:07:12Z")

</div>

And the module docs.
