# Finding out what groups a host is a member of in a template?

**URL:** <https://forum.ansible.com/t/finding-out-what-groups-a-host-is-a-member-of-in-a-template/16697>\
**Category:** Ansible Project\
**Created:** [November 5, 2014, 3:16am UTC](https://forum.ansible.com/t/finding-out-what-groups-a-host-is-a-member-of-in-a-template/16697 "2014-11-05T03:16:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Burton](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@Kevin\_Burton](https://forum.ansible.com/u/Kevin_Burton)\
**Post date:** [November 5, 2014, 3:16am UTC](https://forum.ansible.com/t/finding-out-what-groups-a-host-is-a-member-of-in-a-template/16697/1 "2014-11-05T03:16:40Z")

</div>

For the life of me I can’t seem to find this in the docs but I’m sure it’s possible.

I have a template and I want to expand a string to all the groups that host is a member of.

I’m using them as tags in our monitoring system.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [November 5, 2014, 3:35am UTC](https://forum.ansible.com/t/finding-out-what-groups-a-host-is-a-member-of-in-a-template/16697/2 "2014-11-05T03:35:17Z")

</div>

The group\_names variable will hold that info. It is a list of all groups that the current host is a member of.
