diff options
author | Thomas Wiest <twiest@users.noreply.github.com> | 2015-06-08 10:57:35 -0400 |
---|---|---|
committer | Thomas Wiest <twiest@users.noreply.github.com> | 2015-06-08 10:57:35 -0400 |
commit | d30276dac07b3df32aa02711e27e94e90d925c89 (patch) | |
tree | 66074483c40a232a00c4cd3b87633d3431bd2ed6 /playbooks/openstack/openshift-cluster/terminate.yml | |
parent | e03efb3d8570981ab818bf1b18c01e3573977ba3 (diff) | |
parent | 901f0ee491efb34f9788e11dd6d572928146da91 (diff) | |
download | openshift-d30276dac07b3df32aa02711e27e94e90d925c89.tar.gz openshift-d30276dac07b3df32aa02711e27e94e90d925c89.tar.bz2 openshift-d30276dac07b3df32aa02711e27e94e90d925c89.tar.xz openshift-d30276dac07b3df32aa02711e27e94e90d925c89.zip |
Merge pull request #186 from lhuard1A/os
Implement OpenStack provider for openshift-ansible
Diffstat (limited to 'playbooks/openstack/openshift-cluster/terminate.yml')
-rw-r--r-- | playbooks/openstack/openshift-cluster/terminate.yml | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/playbooks/openstack/openshift-cluster/terminate.yml b/playbooks/openstack/openshift-cluster/terminate.yml new file mode 100644 index 000000000..2f05f0992 --- /dev/null +++ b/playbooks/openstack/openshift-cluster/terminate.yml @@ -0,0 +1,43 @@ +- name: Terminate instance(s) + hosts: localhost + connection: local + gather_facts: no + vars_files: + - vars.yml + tasks: + - set_fact: cluster_group=tag_env_{{ cluster_id }} + - add_host: + name: "{{ item }}" + groups: oo_hosts_to_terminate + ansible_ssh_user: "{{ deployment_vars[deployment_type].ssh_user }}" + ansible_sudo: "{{ deployment_vars[deployment_type].sudo }}" + with_items: groups[cluster_group] | default([]) + +- hosts: oo_hosts_to_terminate + +- hosts: localhost + connection: local + gather_facts: no + vars_files: + - vars.yml + tasks: + - name: Retrieve the floating IPs + shell: "neutron floatingip-list | awk '/{{ hostvars[item].ansible_default_ipv4.address }}/ {print $2}'" + with_items: groups['oo_hosts_to_terminate'] | default([]) + register: floating_ips_to_delete + + - name: Terminate instance(s) + nova_compute: + name: "{{ hostvars[item].os_name }}" + state: absent + with_items: groups['oo_hosts_to_terminate'] | default([]) + + - name: Delete floating IPs + command: "neutron floatingip-delete {{ item.stdout }}" + with_items: floating_ips_to_delete.results | default([]) + + - name: Destroy the network + command: "heat stack-delete {{ openstack_network_prefix }}-stack" + register: stack_delete_result + changed_when: stack_delete_result.rc == 0 + failed_when: stack_delete_result.rc != 0 and 'could not be found' not in stack_delete_result.stdout |