# selecting hosts from multiple host groups in playbook

**URL:** <https://forum.ansible.com/t/selecting-hosts-from-multiple-host-groups-in-playbook/31650>\
**Category:** Ansible Project\
**Created:** [November 13, 2019, 2:59pm UTC](https://forum.ansible.com/t/selecting-hosts-from-multiple-host-groups-in-playbook/31650 "2019-11-13T14:59:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jepper](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@jepper](https://forum.ansible.com/u/jepper)\
**Post date:** [November 13, 2019, 2:59pm UTC](https://forum.ansible.com/t/selecting-hosts-from-multiple-host-groups-in-playbook/31650/1 "2019-11-13T14:59:12Z")

</div>

The intent is to hit the following hosts

host\_group01

host\_group02

another\_host\_group provided it’s also in the group environment\_test

I’ve tried something along this in the playbook

- hosts: ~host\_group(01:02):another\_host\_group:&environment\_test

But this appears to exclude any host that is not in environment\_test, and missing host\_group01 and host\_group02

How can I isolate another\_host\_group:&environment\_test ? I am struggling to work out a regex or find a way modify the hostgroup computation away from the default, in math the equivalent of 2\*(3+4).
