# select hosts via multiple && tags

**URL:** <https://forum.ansible.com/t/select-hosts-via-multiple-tags/17426>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [February 2, 2015, 9:57pm UTC](https://forum.ansible.com/t/select-hosts-via-multiple-tags/17426 "2015-02-02T21:57:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Olliver2](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Mark\_Olliver2](https://forum.ansible.com/u/Mark_Olliver2)\
**Post date:** [February 2, 2015, 9:57pm UTC](https://forum.ansible.com/t/select-hosts-via-multiple-tags/17426/1 "2015-02-02T21:57:35Z")

</div>

Hi,

I am using the AWS inventory script but I need a way to select groups of hosts based on a shared set of tags. I.e many hosts might share the same Project tag but of that group only a few would share the same Product tag however, the Product tag may also contain some hosts from other Projects.

As such I need the hosts which I am acting on to be a subset of these two (actually i am basing it off of three tags but I hope two is enough for the example)

I tried the following in my playbook

hosts: “[tag\_Product=xxx, tag\_Project=yyy]”

Regards

Mark

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [February 3, 2015, 11:33am UTC](https://forum.ansible.com/t/select-hosts-via-multiple-tags/17426/2 "2015-02-03T11:33:57Z")

</div>

hosts: tag\_Product\_xxx:&tag\_Project\_yyy

[http://docs.ansible.com/intro\_dynamic\_inventory.html#static-groups-of-dynamic-groups](http://docs.ansible.com/intro_dynamic_inventory.html#static-groups-of-dynamic-groups)

Giovanni
