# Creating and Naming a Cluster of EC2 Servers Using Ansible

**URL:** <https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154>\
**Category:** Ansible Project\
**Created:** [December 29, 2014, 4:09pm UTC](https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154 "2014-12-29T16:09:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navid\_Paya](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Navid\_Paya](https://forum.ansible.com/u/Navid_Paya)\
**Post date:** [December 29, 2014, 4:09pm UTC](https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154/1 "2014-12-29T16:09:03Z")

</div>

Hi  
I’m trying to automate creating and destroying our staging environment. So far, I have a playbook to create the cluster:

`

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [January 10, 2015, 1:26pm UTC](https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154/2 "2015-01-10T13:26:57Z")

</div>

I’m doing this by registering the results of the ec2 provisioning task and then cycle through the hosts in a subsequent task for creating the dns records.

---

<div class="post-metadata">

**Author:** ![Navid\_Paya](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Navid\_Paya](https://forum.ansible.com/u/Navid_Paya)\
**Post date:** [January 10, 2015, 1:55pm UTC](https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154/3 "2015-01-10T13:55:35Z")

</div>

Thanks for the reply, Dan. Do you have the code available somewhere?

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [January 10, 2015, 2:40pm UTC](https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154/4 "2015-01-10T14:40:32Z")

</div>

On the run now but will share this later.

Btw, are you really missing the task of allocating the EIPs to the instances? This would go before the route53 task.

Dan.

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [January 10, 2015, 2:55pm UTC](https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154/5 "2015-01-10T14:55:02Z")

</div>

Hope you can get some inspiration from here: [https://github.com/danvaida/Atlassian-Stash-Ansible/blob/master/ec2.yml](https://github.com/danvaida/Atlassian-Stash-Ansible/blob/master/ec2.yml)

---

<div class="post-metadata">

**Author:** ![Navid\_Paya](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Navid\_Paya](https://forum.ansible.com/u/Navid_Paya)\
**Post date:** [January 11, 2015, 4:14am UTC](https://forum.ansible.com/t/creating-and-naming-a-cluster-of-ec2-servers-using-ansible/17154/6 "2015-01-11T04:14:11Z")

</div>

Thanks a bunch, Dan. That is helpful. My instances are all VPC instances and I use ELB for all of them so just the private IP works fine for it.
