# ec2 parallel launch

**URL:** <https://forum.ansible.com/t/ec2-parallel-launch/17548>\
**Category:** Ansible Project\
**Created:** [February 18, 2015, 11:46am UTC](https://forum.ansible.com/t/ec2-parallel-launch/17548 "2015-02-18T11:46:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Wasilyev1](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@Alexey\_Wasilyev1](https://forum.ansible.com/u/Alexey_Wasilyev1)\
**Post date:** [February 18, 2015, 11:46am UTC](https://forum.ansible.com/t/ec2-parallel-launch/17548/1 "2015-02-18T11:46:43Z")

</div>

Hello!

Is there any way to launch multiple different vm’s in parallel?  
When I set wait=yes to the ec2 module - vm’s are launched one by one, which can be very slow. In case of wait=yes - vm’s are launched rather faster, but I can’t get they ip/hostname for the next steps.

Any ideas?

---

<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:** [February 21, 2015, 12:11pm UTC](https://forum.ansible.com/t/ec2-parallel-launch/17548/2 "2015-02-21T12:11:31Z")

</div>

What do you mean by “slow”?  
Just use _register_ and in a next task you can get the IP of the launched instances by parsing _instances_ from the registered variable.

---

<div class="post-metadata">

**Author:** ![Alexey\_Wasilyev1](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@Alexey\_Wasilyev1](https://forum.ansible.com/u/Alexey_Wasilyev1)\
**Post date:** [February 21, 2015, 6:21pm UTC](https://forum.ansible.com/t/ec2-parallel-launch/17548/3 "2015-02-21T18:21:38Z")

</div>

When I start instances with wait=yes - they start one by one, ~1 instance per minute. I need to launch 10 instances, so it tooks 10 minutes.

Can you explain your idea with _register_ with few lines of code\*?\*

---

<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:** [February 21, 2015, 7:10pm UTC](https://forum.ansible.com/t/ec2-parallel-launch/17548/4 "2015-02-21T19:10:26Z")

</div>

Hmm… There must be something else happening there. I’m launching 5 instances using the count parameter in about 30s.  
I must say, there are some gotchas while using the cloud modules in regards to the serial parameter but I don’t think that’s the case here.  
Anyhow, the documentation page of the ec2 module has plenty of code examples: [http://docs.ansible.com/ec2\_module.html](http://docs.ansible.com/ec2_module.html)  
If that is not enough, take a look at this: [https://github.com/danvaida/ansible-aws-squid3/blob/master/ec2.yml](https://github.com/danvaida/ansible-aws-squid3/blob/master/ec2.yml)  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![Alexey\_Wasilyev1](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@Alexey\_Wasilyev1](https://forum.ansible.com/u/Alexey_Wasilyev1)\
**Post date:** [February 21, 2015, 8:40pm UTC](https://forum.ansible.com/t/ec2-parallel-launch/17548/5 "2015-02-21T20:40:02Z")

</div>

I launch 10 instances using with\_items:

ec2:  
count:1  
tags: …  
with\_items: vms\_array

I can’t use count more than 1, because every instance can have different ami, differrent type, different tags. So I need to launch them one by one.  
Is there any way to get public\_ip / public\_hostame from instance, launched with wait=no?

---

<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:** [February 21, 2015, 8:58pm UTC](https://forum.ansible.com/t/ec2-parallel-launch/17548/6 "2015-02-21T20:58:23Z")

</div>

Ah, now I see.  
You should be able to do that if you tag the instances and then use the ec2.py inventory script to get the info you need.  
I think the in-memory inventory wouldn’t be much of a help in your use case.

Dan.
