summaryrefslogtreecommitdiffstats
path: root/playbooks/aws/openshift-master
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2015-04-21 16:57:27 -0400
committerThomas Wiest <twiest@users.noreply.github.com>2015-04-21 16:57:27 -0400
commit8ca180543f51cee54a688fb4d83956916b6d6c8b (patch)
tree555eb0dfb0c3d2a00576200e7c4815a64bdbd53e /playbooks/aws/openshift-master
parent89c74233535537d7daae41730e22b7133870e40d (diff)
parentba5ae4dbc7741af1963df36fd92bcd0af03c6b4f (diff)
downloadopenshift-8ca180543f51cee54a688fb4d83956916b6d6c8b.tar.gz
openshift-8ca180543f51cee54a688fb4d83956916b6d6c8b.tar.bz2
openshift-8ca180543f51cee54a688fb4d83956916b6d6c8b.tar.xz
openshift-8ca180543f51cee54a688fb4d83956916b6d6c8b.zip
Merge pull request #166 from detiber/awsTerminate
aws terminate playbook improvements
Diffstat (limited to 'playbooks/aws/openshift-master')
-rw-r--r--playbooks/aws/openshift-master/terminate.yml55
1 files changed, 1 insertions, 54 deletions
diff --git a/playbooks/aws/openshift-master/terminate.yml b/playbooks/aws/openshift-master/terminate.yml
index a790336b1..07d9961bc 100644
--- a/playbooks/aws/openshift-master/terminate.yml
+++ b/playbooks/aws/openshift-master/terminate.yml
@@ -1,55 +1,2 @@
---
-- name: Populate oo_masters_to_terminate host group
- hosts: localhost
- gather_facts: no
- tasks:
- - name: Evaluate oo_masters_to_terminate
- add_host: name={{ item }} groups=oo_masters_to_terminate
- with_items: oo_host_group_exp | default([])
-
-- name: Gather dynamic inventory variables for hosts to terminate
- hosts: oo_masters_to_terminate
- gather_facts: no
-
-- name: Terminate instances
- hosts: localhost
- connection: local
- gather_facts: no
- vars:
- host_vars: "{{ hostvars
- | oo_select_keys(groups['oo_masters_to_terminate']) }}"
- tasks:
- - name: Terminate instances
- ec2:
- state: absent
- instance_ids: ["{{ item.ec2_id }}"]
- region: "{{ item.ec2_region }}"
- ignore_errors: yes
- register: ec2_term
- with_items: host_vars
- when: "'oo_masters_to_terminate' in groups"
-
- # Fail if any of the instances failed to terminate with an error other
- # than 403 Forbidden
- - fail: msg=Terminating instance {{ item.item.ec2_id }} failed with message {{ item.msg }}
- when: "'oo_masters_to_terminate' in groups and item.failed and not item.msg | search(\"error: EC2ResponseError: 403 Forbidden\")"
- with_items: ec2_term.results
-
- - name: Stop instance if termination failed
- ec2:
- state: stopped
- instance_ids: ["{{ item.item.ec2_id }}"]
- region: "{{ item.item.ec2_region }}"
- register: ec2_stop
- when: item.failed
- with_items: ec2_term.results
- when: "'oo_masters_to_terminate' in groups"
-
- - name: Rename stopped instances
- ec2_tag: resource={{ item.item.item.ec2_id }} region={{ item.item.item.ec2_region }} state=present
- args:
- tags:
- Name: "{{ item.item.item.ec2_tag_Name }}-terminate"
- with_items: ec2_stop.results
- when: "'oo_masters_to_terminate' in groups"
-
+- include: ../terminate.yml