# Need help with a static inventory of dynamic groups

**URL:** <https://forum.ansible.com/t/need-help-with-a-static-inventory-of-dynamic-groups/21845>\
**Category:** Ansible Project\
**Created:** [June 23, 2016, 2:47pm UTC](https://forum.ansible.com/t/need-help-with-a-static-inventory-of-dynamic-groups/21845 "2016-06-23T14:47:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pporada](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@pporada](https://forum.ansible.com/u/pporada)\
**Post date:** [June 23, 2016, 2:47pm UTC](https://forum.ansible.com/t/need-help-with-a-static-inventory-of-dynamic-groups/21845/1 "2016-06-23T14:47:48Z")

</div>

```auto
===================================================
Here is my static inventory of dynamic groups

[tag_ENV_prod]
[tag_ROLES_bastion]
[prod-bastion:children]
tag_ROLES_bastion:&tag_ENV_prod
[prod-servers:children]
tag_ENV_prod:!tag_ROLES_bastion

===================================================
Calling the groups via an adhoc ansible command does NOT work.

$ ansible 'prod-bastion' -i ec2.py --list-hosts
 [WARNING]: provided hosts list is empty, only localhost is available
  hosts (0):
$ ansible 'prod-servers' -i ec2.py --list-hosts
 [WARNING]: provided hosts list is empty, only localhost is available
  hosts (0):

===================================================
This however works

$ ansible 'tag_ROLES_bastion:&tag_ENV_prod' -i ec2.py --list-hosts
  hosts (1):
    192.168.1.4
$ ansible '\!tag_ROLES_bastion:tag_ENV_prod' -i ec2.py --list-hosts
  hosts (8):
    192.168.1.12
    192.168.1.30

```

---

<div class="post-metadata">

**Author:** ![pporada](https://avatars.discourse-cdn.com/v4/letter/p/b4bc9f/32.png) [@pporada](https://forum.ansible.com/u/pporada)\
**Post date:** [June 23, 2016, 2:48pm UTC](https://forum.ansible.com/t/need-help-with-a-static-inventory-of-dynamic-groups/21845/2 "2016-06-23T14:48:58Z")

</div>

Why is it not possible to perform complex pattern matching in the inventory? How do other companies handle this?
