# shortcut to group dns hostname

**URL:** <https://forum.ansible.com/t/shortcut-to-group-dns-hostname/12279>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [February 1, 2013, 1:17pm UTC](https://forum.ansible.com/t/shortcut-to-group-dns-hostname/12279 "2013-02-01T13:17:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 1, 2013, 1:17pm UTC](https://forum.ansible.com/t/shortcut-to-group-dns-hostname/12279/1 "2013-02-01T13:17:44Z")

</div>

A couple of possible suggestions.

(A) one, you could write an inventory script, which serves up this  
information from another data file.

(B) two, you could code-generate the inventory file from another script.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 1, 2013, 1:29pm UTC](https://forum.ansible.com/t/shortcut-to-group-dns-hostname/12279/2 "2013-02-01T13:29:47Z")

</div>

Also, just thinking, it may turn out that these may be intended to be  
different organizations or environments.

(IF) you don't want to ever manage them at seperate times, you could  
put them in different inventory files (like if it was stage vs prod)

I would also be tempted to put those in multiple groups anyway.

If it starts to get complex and you want to invert the order, like say  
"this host is in these groups, not these groups have these hosts",  
this may be an excellent reason  
to have an alternative inventory script. But if you're just starting  
out with things, ignore that for a while, it's not immediately  
necessary.

We could possibly even see a feature in core like:

[someservers]  
asdf.example.com in\_groups=abc,def,ghi

Though that's not something you can presently do.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 1, 2013, 1:30pm UTC](https://forum.ansible.com/t/shortcut-to-group-dns-hostname/12279/3 "2013-02-01T13:30:17Z")

</div>

> [someservers]  
> asdf.example.com in\_groups=abc,def,ghi
> 
> Though that's not something you can presently do.

This also would require some variable interpolation, scratch that idea 🙂
