# Variable to list current host's group membership

**URL:** <https://forum.ansible.com/t/variable-to-list-current-hosts-group-membership/19217>\
**Category:** Ansible Project\
**Created:** [September 9, 2015, 8:20pm UTC](https://forum.ansible.com/t/variable-to-list-current-hosts-group-membership/19217 "2015-09-09T20:20:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [September 9, 2015, 8:20pm UTC](https://forum.ansible.com/t/variable-to-list-current-hosts-group-membership/19217/1 "2015-09-09T20:20:39Z")

</div>

Hi Ansible people,  
I’m labbing some dynamic playbooks stuff, and would like to access a list of the current host’s group membership dynamically. I guess I can scan everyone of them and try and match with inventory\_hostname but was hoping for a better solution.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 9, 2015, 8:33pm UTC](https://forum.ansible.com/t/variable-to-list-current-hosts-group-membership/19217/2 "2015-09-09T20:33:24Z")

</div>

you want "group\_names"

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [September 9, 2015, 8:35pm UTC](https://forum.ansible.com/t/variable-to-list-current-hosts-group-membership/19217/3 "2015-09-09T20:35:33Z")

</div>

ah, of course. Thanks!
