# Inventory Group Name as a Variable?

**URL:** <https://forum.ansible.com/t/inventory-group-name-as-a-variable/21473>\
**Category:** Ansible Project\
**Created:** [May 18, 2016, 1:17pm UTC](https://forum.ansible.com/t/inventory-group-name-as-a-variable/21473 "2016-05-18T13:17:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [May 18, 2016, 1:17pm UTC](https://forum.ansible.com/t/inventory-group-name-as-a-variable/21473/1 "2016-05-18T13:17:37Z")

</div>

I would like to use our inventory group names as a variable in a template file. Has anyone had any success doing this?

---

<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:** [May 18, 2016, 1:26pm UTC](https://forum.ansible.com/t/inventory-group-name-as-a-variable/21473/2 "2016-05-18T13:26:52Z")

</div>

Look at the group\_names variable. It contains a list of all groups the host is in.
