diff options
author | Jason DeTiberus <jdetiber@redhat.com> | 2015-07-10 13:50:03 -0400 |
---|---|---|
committer | Jason DeTiberus <jdetiber@redhat.com> | 2015-07-10 13:57:49 -0400 |
commit | f08e64ac98a62863dfd7b7802338a0a7f4770188 (patch) | |
tree | fa1fa44272de608a55d9c02031981336683cfaf3 /playbooks/aws/openshift-cluster | |
parent | 85966c8d520fbd166e651a2850e701e6339f5835 (diff) | |
download | openshift-f08e64ac98a62863dfd7b7802338a0a7f4770188.tar.gz openshift-f08e64ac98a62863dfd7b7802338a0a7f4770188.tar.bz2 openshift-f08e64ac98a62863dfd7b7802338a0a7f4770188.tar.xz openshift-f08e64ac98a62863dfd7b7802338a0a7f4770188.zip |
Remove outdated playbooks
- Remove aws openshift-node and openshift-master playbooks
- Rmove gce openshift-node and openshift-master playbooks
- Consolidate aws terminate playbooks
Diffstat (limited to 'playbooks/aws/openshift-cluster')
-rw-r--r-- | playbooks/aws/openshift-cluster/terminate.yml | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/playbooks/aws/openshift-cluster/terminate.yml b/playbooks/aws/openshift-cluster/terminate.yml index 617d0d456..361ab2d37 100644 --- a/playbooks/aws/openshift-cluster/terminate.yml +++ b/playbooks/aws/openshift-cluster/terminate.yml @@ -13,4 +13,53 @@ ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}" with_items: groups[scratch_group] | default([]) | difference(['localhost']) -- include: ../terminate.yml +- name: Terminate instances + hosts: localhost + connection: local + gather_facts: no + vars: + host_vars: "{{ hostvars + | oo_select_keys(groups['oo_hosts_to_terminate']) }}" + tasks: + - name: Remove tags from instances + ec2_tag: resource={{ item.ec2_id }} region={{ item.ec2_region }} state=absent + args: + tags: + env: "{{ item['ec2_tag_env'] }}" + host-type: "{{ item['ec2_tag_host-type'] }}" + env-host-type: "{{ item['ec2_tag_env-host-type'] }}" + with_items: host_vars + when: "'oo_hosts_to_terminate' in groups" + + - 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_hosts_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_hosts_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: "'oo_hosts_to_terminate' in groups and item.failed" + with_items: ec2_term.results + + - 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_hosts_to_terminate' in groups" |