# Sites & Roles

**URL:** <https://forum.ansible.com/t/sites-roles/13873>\
**Category:** Ansible Project\
**Created:** [November 9, 2013, 10:02am UTC](https://forum.ansible.com/t/sites-roles/13873 "2013-11-09T10:02:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikhail\_Sobolev](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@Mikhail\_Sobolev](https://forum.ansible.com/u/Mikhail_Sobolev)\
**Post date:** [November 9, 2013, 10:02am UTC](https://forum.ansible.com/t/sites-roles/13873/1 "2013-11-09T10:02:48Z")

</div>

Hi,

(Disclaimer: I’m very new to ansible so I easily might miss something very straightforward.)

I have a number of sites, e.g. site1, site2, …, siteN. Each site has a number of machines that play a particular “role”, e.g. roleA1, roleA2, roleB1, roleC1, …

I easily created an inventory for sites:

[siteX]  
[roleA1.siteX.example.com](http://roleA1.siteX.example.com)  
…

However I could not find a way to have a special group for all available roleY machines. I tried

[roleY]  
roleY[1:9].\*.example.com

but the result was not what I expected.

Any suggestions on what I should read to better understand how the things work?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [November 11, 2013, 5:21pm UTC](https://forum.ansible.com/t/sites-roles/13873/2 "2013-11-11T17:21:53Z")

</div>

the wildcard won’t work, but you can add another range:

roleY[1:9].site[1:9].[example.com](http://example.com)

---

<div class="post-metadata">

**Author:** ![Mikhail\_Sobolev](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@Mikhail\_Sobolev](https://forum.ansible.com/u/Mikhail_Sobolev)\
**Post date:** [December 16, 2013, 7:04pm UTC](https://forum.ansible.com/t/sites-roles/13873/3 "2013-12-16T19:04:32Z")

</div>

Thanks, Brian.

As we discussed today on IRC:

20:54 my site names are 0000 … 9999 (not that many yet, but they grow :))  
20:54 so i’d specify [0000:9999]?  
20:54 [0000:9999]  
20:54 yep  
20:55 interesting: it’s so simple 🙂 meanwhile i wrote a dynamic inventory 🙂  
20:57 ah…  
20:58 i just realised: the example i gave in the post, is not totally accurate ☹  
20:59 the host name looks like roleX.siteYYYY...example.com  
21:00 where is geographical area (can be 0-2 components), and is either “test” (where is not present) or “prod” (where is 1-2 name components)  
21:00 bcoca: do you think i could use ranges in this case as well?  
21:01 not sure

So, I will stick to my dynamic inventory script for now.
