# playbook, inventory, and group\_names

**URL:** <https://forum.ansible.com/t/playbook-inventory-and-group-names/30026>\
**Category:** Ansible Project\
**Created:** [March 29, 2019, 5:57pm UTC](https://forum.ansible.com/t/playbook-inventory-and-group-names/30026 "2019-03-29T17:57:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mauricio\_Tavares](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mauricio\_Tavares](https://forum.ansible.com/u/Mauricio_Tavares)\
**Post date:** [March 29, 2019, 5:57pm UTC](https://forum.ansible.com/t/playbook-inventory-and-group-names/30026/1 "2019-03-29T17:57:20Z")

</div>

So let's say I have an inventory like this:

[cars]  
honda  
volvo  
saab

[motos]  
aprilla  
moto-guzzi

and in my playbook I am referring to motorcycles only

- hosts: motos

> From what I understand, group\_names returns the groups defined in the

inventory. How can I get a list of the host groups I am using in the  
playbook?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 29, 2019, 6:16pm UTC](https://forum.ansible.com/t/playbook-inventory-and-group-names/30026/2 "2019-03-29T18:16:24Z")

</div>

You can't ref this thread  
[https://groups.google.com/forum/#!msg/ansible-project/WntLXpN\_gtg/HQ7PnjLZBAAJ](https://groups.google.com/forum/#!msg/ansible-project/WntLXpN_gtg/HQ7PnjLZBAAJ)
