# terminate instance behind ELB

**URL:** <https://forum.ansible.com/t/terminate-instance-behind-elb/18045>\
**Category:** Ansible Project\
**Created:** [April 21, 2015, 10:04pm UTC](https://forum.ansible.com/t/terminate-instance-behind-elb/18045 "2015-04-21T22:04:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rahul\_Mehrotra](https://avatars.discourse-cdn.com/v4/letter/r/5e9695/32.png) [@Rahul\_Mehrotra](https://forum.ansible.com/u/Rahul_Mehrotra)\
**Post date:** [April 21, 2015, 10:04pm UTC](https://forum.ansible.com/t/terminate-instance-behind-elb/18045/1 "2015-04-21T22:04:22Z")

</div>

Hi,  
I am trying to figure out if there is a way to terminate instance which are in private subnet behind ELB using dynamic inventory.

I have my ansible script as follows

`

- hosts: localhost  
serial: 1

tasks:

- name: Terminate {{ec2\_id}} instance in {{aws\_region}}  
local\_action:  
module: ec2  
state: ‘absent’  
region: ‘{{region}}’  
instance\_ids: ‘{{ec2\_id}}’

`

Now the issue is that ; the instance do not have a public IP, if I am modifying ec2.ini to get private IP and set hosts to like tag\_Name\_webservers  
then ansible tries to SSH inside the instance and fails.

If I set it to localhost it is not able to get the instance\_id and exits with ec2\_id not found

Can anyone direct me with a correct method to do this ?

Thank you

---

<div class="post-metadata">

**Author:** ![Raghu\_Udiyar](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@Raghu\_Udiyar](https://forum.ansible.com/u/Raghu_Udiyar)\
**Post date:** [April 22, 2015, 7:24am UTC](https://forum.ansible.com/t/terminate-instance-behind-elb/18045/2 "2015-04-22T07:24:51Z")

</div>

Disable gather\_facts, so ansible won’t try to contact the instance :

`
