# group name from variable

**URL:** <https://forum.ansible.com/t/group-name-from-variable/19474>\
**Category:** Ansible Project\
**Created:** [October 9, 2015, 4:02pm UTC](https://forum.ansible.com/t/group-name-from-variable/19474 "2015-10-09T16:02:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![francesco.savignago](https://avatars.discourse-cdn.com/v4/letter/f/a8b319/32.png) [@francesco.savignago](https://forum.ansible.com/u/francesco.savignago)\
**Post date:** [October 9, 2015, 4:02pm UTC](https://forum.ansible.com/t/group-name-from-variable/19474/1 "2015-10-09T16:02:11Z")

</div>

Hi!  
I would like to run a role something like

- name: debug role  
debug: msg=“{{ hostvars[item].ansible\_host }}”  
with\_items: groups[{{ALLOWED\_HOSTS\_GROUP}}]

however the syntax groups[{{ALLOWED\_HOSTS\_GROUP}}] is not accepted.  
Is there any other way to pass a group name from a variable defined e.g. in a playbook?

Thanks for your support.

---

<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:** [October 9, 2015, 5:04pm UTC](https://forum.ansible.com/t/group-name-from-variable/19474/2 "2015-10-09T17:04:27Z")

</div>

with\_items: "{{ groups[ALLOWED\_HOSTS\_GROUP] }}"
