# Deregister EC2 instances from an ELB one by one, transnsfer a .deb package & install  and register each onto same ELB back.

**URL:** <https://forum.ansible.com/t/deregister-ec2-instances-from-an-elb-one-by-one-transnsfer-a-deb-package-install-and-register-each-onto-same-elb-back/21445>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [May 15, 2016, 2:56pm UTC](https://forum.ansible.com/t/deregister-ec2-instances-from-an-elb-one-by-one-transnsfer-a-deb-package-install-and-register-each-onto-same-elb-back/21445 "2016-05-15T14:56:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj\_Boruah](https://avatars.discourse-cdn.com/v4/letter/r/c67d28/32.png) [@Raj\_Boruah](https://forum.ansible.com/u/Raj_Boruah)\
**Post date:** [May 15, 2016, 2:56pm UTC](https://forum.ansible.com/t/deregister-ec2-instances-from-an-elb-one-by-one-transnsfer-a-deb-package-install-and-register-each-onto-same-elb-back/21445/1 "2016-05-15T14:56:44Z")

</div>

Hi,

I am new to Ansible and trying to automate the following scenario on AWS:

1. Get the instance ids registered to an elb from within an elb. (I do not want to specify the instaces in a harcoded way)
2. Deregister one instance and perform my needed operation in that instance (e.g. edit /var/lib/monit/id )
3. Register that instance back into the same elb. Repeat the same until all instances in that elb are updated/upgraded.

I tried follwoing:

- ec2\_elb\_facts for instance ids (it does not provide host name or public ids) and create a group for the instances
- ec2\_elb to deregister instances using the group created above
- I am not sure how to log into the instances on the fly as ec2\_elb\_facts does not provide hostname or IPs.

Can anyone please help me on this ? If anyone can provide me the scripts, that would be of great help.

Thanks,

Raj.
