Commit 532c62f9 by John Jarvis

deregistering instance along with termination

parent d239cb27
......@@ -33,16 +33,22 @@
# in as a -e variable
- gh_users
post_tasks:
- debug: msg={{ launch_ids }}
- debug: msg={{ termination_ids }}
- name: get instance id for elb registration
local_action:
module: ec2_lookup
region: us-east-1
tags:
Name: "{{ name_tag }}"
register: ec2_info
when: elb
sudo: False
- name: register instance into an elb if one was provided
local_action:
module: ec2_elb
region: "{{ region }}"
instance_id: "{{ item }}"
instance_id: "{{ ec2_info.instance_ids[0] }}"
state: present
ec2_elbs:
- "{{ elb }}"
when: elb
sudo: False
with_items: "{{ launch_ids }}"
......@@ -16,11 +16,6 @@
debug: msg="Too many results returned, not terminating!"
when: terminate_instance == true and tag_lookup.instance_ids|length > 1
- name: launch_ec2 | remember the instance id of the terminated instance
set_fact:
termination_ids: ${tag_lookup.instance_ids}
when: terminate_instance == true
- name: terminating single instance
local_action:
module: ec2
......@@ -29,6 +24,14 @@
instance_ids: ${tag_lookup.instance_ids}
when: terminate_instance == true and tag_lookup.instance_ids|length == 1
- name: deregister instance from any elb it was previously in
local_action:
module: ec2_elb
region: "{{ region }}"
instance_id: "{{ tag_lookup.instance_ids[0] }}"
state: absent
when: terminate_instance == true and elb
- name: launch_ec2 | Launch ec2 instance
local_action:
module: ec2
......@@ -43,10 +46,6 @@
zone: "{{ zone }}"
register: ec2
- name: launch_ec2 | remember the instance id of the launched instances
set_fact:
launch_ids: ${ec2.instances}
- name: launch_ec2 | Add DNS name
local_action:
module: route53
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment