ec2 parallel launch

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?

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.

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*?*

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
If that is not enough, take a look at this: https://github.com/danvaida/ansible-aws-squid3/blob/master/ec2.yml
Hope this helps.

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?

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.