# How to get host/group name for dynamic inventory?

**URL:** <https://forum.ansible.com/t/how-to-get-host-group-name-for-dynamic-inventory/21072>\
**Category:** Ansible Project\
**Created:** [April 5, 2016, 7:05pm UTC](https://forum.ansible.com/t/how-to-get-host-group-name-for-dynamic-inventory/21072 "2016-04-05T19:05:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Souren\_Abeghyan](https://avatars.discourse-cdn.com/v4/letter/s/7cd45c/32.png) [@Souren\_Abeghyan](https://forum.ansible.com/u/Souren_Abeghyan)\
**Post date:** [April 5, 2016, 7:05pm UTC](https://forum.ansible.com/t/how-to-get-host-group-name-for-dynamic-inventory/21072/1 "2016-04-05T19:05:05Z")

</div>

Having ec2 dynamic inventory and pattern in hosts:

```auto
- hosts: [tag_Name_m*]

```

which variable holds the full host/tag/group name?

---

<div class="post-metadata">

**Author:** ![Zacharias\_Thompson](https://avatars.discourse-cdn.com/v4/letter/z/13edae/32.png) [@Zacharias\_Thompson](https://forum.ansible.com/u/Zacharias_Thompson)\
**Post date:** [April 7, 2016, 3:50am UTC](https://forum.ansible.com/t/how-to-get-host-group-name-for-dynamic-inventory/21072/2 "2016-04-07T03:50:37Z")

</div>

You can always see all the variables available to you by doing something like what was posted here: [https://gryzli.info/2015/05/29/ansible-dump-all-variables/](https://gryzli.info/2015/05/29/ansible-dump-all-variables/)

The other option would be to just create a task that prints out current variables, example:

`

- name: See Variables  
hosts: [tag\_name\_m\*]  
connection: local  
tasks:
- name: see vars

`

debug: var=vars

---

<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:** [April 7, 2016, 2:36pm UTC](https://forum.ansible.com/t/how-to-get-host-group-name-for-dynamic-inventory/21072/3 "2016-04-07T14:36:10Z")

</div>

play\_hosts has the ‘list of current hosts in play’
