# obtaining hostnames and groups

**URL:** <https://forum.ansible.com/t/obtaining-hostnames-and-groups/29722>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [February 20, 2019, 4:49pm UTC](https://forum.ansible.com/t/obtaining-hostnames-and-groups/29722 "2019-02-20T16:49:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![S\_C\_Rigler](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@S\_C\_Rigler](https://forum.ansible.com/u/S_C_Rigler)\
**Post date:** [February 20, 2019, 4:49pm UTC](https://forum.ansible.com/t/obtaining-hostnames-and-groups/29722/1 "2019-02-20T16:49:24Z")

</div>

Use "{{ group\_names }}". There can be more than one group, so you'll  
likely need to join them with something like "{{ group\_names | join(',  
') }}"

--Steve
