# Can I create host group aliases when using EC2 inventory?

**URL:** <https://forum.ansible.com/t/can-i-create-host-group-aliases-when-using-ec2-inventory/15143>\
**Category:** Ansible Developer\
**Created:** [May 2, 2014, 2:37pm UTC](https://forum.ansible.com/t/can-i-create-host-group-aliases-when-using-ec2-inventory/15143 "2014-05-02T14:37:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darren\_Hobbs](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@Darren\_Hobbs](https://forum.ansible.com/u/Darren_Hobbs)\
**Post date:** [May 2, 2014, 2:37pm UTC](https://forum.ansible.com/t/can-i-create-host-group-aliases-when-using-ec2-inventory/15143/1 "2014-05-02T14:37:27Z")

</div>

Hi,

I’ve got an existing inventory file that hard-codes our EC2 hosts. I’m trying to move over to the dynamic inventory, using tags. The problem I have is that all my roles refer to hosts such as ‘webservers’, ‘logstash’ etc. and the EC2 dynamic inventory groups look like ‘tag\_class\_webservers’ etc.

I’d like to be able to tell ansible to create a host group called ‘webservers’ containing every instance tagged ‘tag\_class\_webservers’ (or simply aliases to it), so that I don’t have to modify all my playbooks to work with the dynamic inventory. Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![Jesse\_Keating](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jesse\_Keating](https://forum.ansible.com/u/Jesse_Keating)\
**Post date:** [May 2, 2014, 3:06pm UTC](https://forum.ansible.com/t/can-i-create-host-group-aliases-when-using-ec2-inventory/15143/2 "2014-05-02T15:06:19Z")

</div>

add\_host: name={{ item }} groups=webservers  
with\_items: groups['tag\_class\_webservers']

Something along those lines should help you.

-jlk

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 2, 2014, 3:20pm UTC](https://forum.ansible.com/t/can-i-create-host-group-aliases-when-using-ec2-inventory/15143/3 "2014-05-02T15:20:18Z")

</div>

This is more of a general question than a -devel topic, but what Jesse noted above should work. However, if you’ve specified the tags when creating those instances and are using the ec2.py inventory script those should be picked up automatically.

The one caveat for both situations though, is that the set of hosts being operated on currently will not change - you have to create another play (within the same playbook) to pick up the new hosts.

---

<div class="post-metadata">

**Author:** ![Darren\_Hobbs](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@Darren\_Hobbs](https://forum.ansible.com/u/Darren_Hobbs)\
**Post date:** [May 4, 2014, 10:58am UTC](https://forum.ansible.com/t/can-i-create-host-group-aliases-when-using-ec2-inventory/15143/4 "2014-05-04T10:58:57Z")

</div>

I’ve specified the tags and the ec2 inventory is working. I guess what I really want is an inventory that says ‘take an input inventory and augment it’. Inventory inheritance 🙂

WRT to asking on the wrong list, sorry about that. I thought it was a little weird - I followed the ‘User Mailing List’ link on [http://docs.ansible.com/faq.html#i-don-t-see-my-question-here](http://docs.ansible.com/faq.html#i-don-t-see-my-question-here)

Possibly that link should go to [https://groups.google.com/forum/#!forum/ansible-project](https://groups.google.com/forum/#!forum/ansible-project) instead?

Thanks,  
-Darren

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 6, 2014, 3:41am UTC](https://forum.ansible.com/t/can-i-create-host-group-aliases-when-using-ec2-inventory/15143/5 "2014-05-06T03:41:56Z")

</div>

Indeed it should, can you please file a ticket at [github.com/ansible/ansible](http://github.com/ansible/ansible) about the link, or otherwise send us a patch for the documentation page?

Thanks!
