You can get the instance id by using this task:

- name: Get the facts about the ELB
     ec2_elb_facts:
       names: rbgeek-dev-web-elb
       region: "eu-west-1"
     register: elb_facts

   - name: Instance(s) ID that are currently register to the ELB
     debug:
       msg: "{{ elb_facts.elbs.0.instances }}"

Then you can use the ec2_id to get it's ip address, may be a minor 
modification to this plugin 
<https://github.com/jonhadfield/ansible-lookups/blob/master/v2/aws_ec2_instance_private_ip_from_name.py>
 
help you or you can find some other way to get it done.

Hope that point you to the right direction.

On Tuesday, May 10, 2016 at 6:38:43 PM UTC+5, [email protected] wrote:
>
> Dear all,
>
> I am new to ansible, I want to populate my host file by finding the 
> private ip of instances which are behind the ec2 elb. So that my inventory 
> file is consistent with actual running instances.
> I don't seem to find a way to do that. any pointer will be helpful.
>
> Thanks,
> Saurabh J
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a4312e6f-c6b5-43f6-92fa-ce99f1f839fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to