ec2 parallel launch

181 views
Skip to first unread message

Alexey Wasilyev

unread,
Feb 18, 2015, 6:46:46 AM2/18/15
to ansible...@googlegroups.com
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?

Dan Vaida

unread,
Feb 21, 2015, 7:11:31 AM2/21/15
to ansible...@googlegroups.com
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.

Alexey Wasilyev

unread,
Feb 21, 2015, 1:21:38 PM2/21/15
to ansible...@googlegroups.com
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

Dan Vaida

unread,
Feb 21, 2015, 2:10:52 PM2/21/15
to ansible...@googlegroups.com
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.

> On Feb 21, 2015, at 7:21 PM, Alexey Wasilyev <awas...@qubell.com> wrote:
>
> 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?
>
> On Saturday, February 21, 2015 at 3:11:31 PM UTC+3, Dan Vaida wrote:
> 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 instancesfrom the registered variable.
>
> On Wednesday, 18 February 2015 12:46:46 UTC+1, Alexey Wasilyev wrote:
> 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?
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/5O7b_2ra5Vk/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d8487d8a-f196-42d8-a1a8-1e242510db84%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Alexey Wasilyev

unread,
Feb 21, 2015, 3:40:07 PM2/21/15
to ansible...@googlegroups.com
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?

Dan Vaida

unread,
Feb 21, 2015, 3:58:34 PM2/21/15
to ansible...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages