IP or DNS name of launched instances by ec2_asg

124 views
Skip to first unread message

biswajit...@commonfloor.com

unread,
Jan 15, 2015, 1:30:28 PM1/15/15
to ansible...@googlegroups.com
Hi, 

After instance launched using   ec2_asg  , I wish to add newly created instance to ansible control machin's host group. 
I need to get the public ip and public dns of launched instances. 

I wonder , if registering the ec2_asg output to a list , say asg_result and then getting the ip (item.public_ip) as asg_result.instances will work ?

Please let me know the best practices for the same .

Regards,
Biswajit


Using a smartphone? Try our app for property search and app for residential communities.
------------------------------------------------------------------------------------------------------------------
This e-mail and any files transmitted with it may contain confidential and privileged information are for the sole use of the intended recipient(s) . If you are not the intended recipient, please appraise the sender by reply e-mail and destroy all copies and the original message. Any unauthorized disclosure, dissemination, forwarding, printing or copying of this email or any action taken on this e-mail is strictly prohibited and may be unlawful.

Ivan S. Freitas

unread,
Jan 16, 2015, 8:28:01 AM1/16/15
to ansible...@googlegroups.com
On Thu, Jan 15, 2015 at 4:30 PM, <biswajit...@commonfloor.com> wrote:
> Hi,
>
> After instance launched using ec2_asg , I wish to add newly created
> instance to ansible control machin's host group.
> I need to get the public ip and public dns of launched instances.
>
> I wonder , if registering the ec2_asg output to a list , say asg_result and
> then getting the ip (item.public_ip) as asg_result.instances will work ?
>
> Please let me know the best practices for the same .

Have you considered using the ec2 dynamic inventory plugin with tags?
Instead of adding the public ip's to the inventory, ansible can return a
list of them of the machines with a given tag. See [1] for the
documentation about it. It can also return the ip's based on other
information, such as security groups, etc.

[1]: http://docs.ansible.com/intro_dynamic_inventory.html#example-aws-ec2-external-inventory-script

--
Ivan Sichmann Freitas
GNU/Linux user #509059
SDF MetaArpa Member http://isf.sdf.org/about.html

Arbab Nazar

unread,
Jan 17, 2015, 3:52:31 AM1/17/15
to ansible...@googlegroups.com

Hi Biswajit, 

can you please paste the output of the "asg_result" and i'll try to help you that how you can add the ip to the hosts file. 

@Ivan, he also give you really good suggestion but if you want to register the ip address then please paste the output of the "asg_result". Thanks

Biswajit Banerjee

unread,
Jan 19, 2015, 7:18:42 AM1/19/15
to ansible...@googlegroups.com
Thank you Evan and Arbab.

My use case here, as soon as autoscale take place and new instance are UP..I have few more plays to start ...like for an example  ...installing and configuring  git ...apache.....other needed settings.... so those role should identify the newly launched
instances. So need a mechanism for that. 

Please note :All these play/roles is part of a same playbook.

 

Regards,
Biswajit


--
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/b1YRa4Ohdc0/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/ce6c56e5-e0f5-4ba7-af5c-ae7b9e1cbfe7%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ivan S. Freitas

unread,
Jan 19, 2015, 11:43:22 AM1/19/15
to ansible...@googlegroups.com
On Mon, Jan 19, 2015 at 10:18 AM, Biswajit Banerjee
<biswajit...@commonfloor.com> wrote:
> Thank you Evan and Arbab.
>
> My use case here, as soon as autoscale take place and new instance are UP..I
> have few more plays to start ...like for an example ...installing and
> configuring git ...apache.....other needed settings.... so those role
> should identify the newly launched
> instances. So need a mechanism for that.

If what you're executing in the servers has no side-effects and your
plays are properly configured to be indempotent, it shouldn't matter
if the machine is a fresh instance or an "old" one; running ansible in
each one of them should make them consistent between themselves (i.e.,
install everything needed in a fresh instance and keeping every other
instance unchanged).
Reply all
Reply to author
Forward
0 new messages