summaryrefslogtreecommitdiffstats
path: root/playbooks/libvirt/openshift-cluster/terminate.yml
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2015-04-20 17:25:57 -0400
committerThomas Wiest <twiest@users.noreply.github.com>2015-04-20 17:25:57 -0400
commit96dd0ab929b7f391eee9b23209aa377537114b72 (patch)
treed1f9aa5becd04097213fe56aa4982bd35830df10 /playbooks/libvirt/openshift-cluster/terminate.yml
parent0722304b2f9c94a2f70054e0a3c7feceaedb195c (diff)
parentdbb252bc04a6488c1fde05dbc325b246fd4a651e (diff)
downloadopenshift-96dd0ab929b7f391eee9b23209aa377537114b72.tar.gz
openshift-96dd0ab929b7f391eee9b23209aa377537114b72.tar.bz2
openshift-96dd0ab929b7f391eee9b23209aa377537114b72.tar.xz
openshift-96dd0ab929b7f391eee9b23209aa377537114b72.zip
Merge pull request #139 from detiber/configUpdatesMaster
Massive refactor, deployment-type support, config updates, reduce duplication
Diffstat (limited to 'playbooks/libvirt/openshift-cluster/terminate.yml')
-rw-r--r--playbooks/libvirt/openshift-cluster/terminate.yml69
1 files changed, 36 insertions, 33 deletions
diff --git a/playbooks/libvirt/openshift-cluster/terminate.yml b/playbooks/libvirt/openshift-cluster/terminate.yml
index c609169d3..b173a09dd 100644
--- a/playbooks/libvirt/openshift-cluster/terminate.yml
+++ b/playbooks/libvirt/openshift-cluster/terminate.yml
@@ -1,41 +1,44 @@
+---
+# TODO: does not handle a non-existant cluster gracefully
+
- 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([])
- vars:
- libvirt_storage_pool_path: "{{ lookup('env','HOME') }}/libvirt-storage-pool-openshift"
- libvirt_storage_pool: 'openshift'
- libvirt_uri: 'qemu:///system'
+ - name: Destroy VMs
+ virt:
+ name: '{{ item[0] }}'
+ command: '{{ item[1] }}'
+ uri: '{{ libvirt_uri }}'
+ with_nested:
+ - groups['oo_hosts_to_terminate']
+ - [ destroy, undefine ]
- tasks:
- - name: List VMs
- virt:
- command: list_vms
- register: list_vms
+ - name: Delete VMs drives
+ command: 'virsh -c {{ libvirt_uri }} vol-delete --pool {{ libvirt_storage_pool }} {{ item }}.qcow2'
+ args:
+ removes: '{{ libvirt_storage_pool_path }}/{{ item }}.qcow2'
+ with_items: groups['oo_hosts_to_terminate']
- - name: Destroy VMs
- virt:
- name: '{{ item[0] }}'
- command: '{{ item[1] }}'
- uri: '{{ libvirt_uri }}'
- with_nested:
- - '{{ list_vms.list_vms }}'
- - [ destroy, undefine ]
- when: item[0]|truncate(cluster_id|length+1, True) == '{{ cluster_id }}-...'
+ - name: Delete the VM cloud-init image
+ file:
+ path: '{{ libvirt_storage_pool_path }}/{{ item }}_cloud-init.iso'
+ state: absent
+ with_items: groups['oo_hosts_to_terminate']
- - name: Delete VMs config drive
- file:
- path: '{{ libvirt_storage_pool_path }}/{{ item }}_configdrive/openstack'
- state: absent
- with_items: '{{ list_vms.list_vms }}'
- when: item|truncate(cluster_id|length+1, True) == '{{ cluster_id }}-...'
+ - name: Remove the cloud-init config directory
+ file:
+ path: '{{ libvirt_storage_pool_path }}/{{ item }}_configdrive/'
+ state: absent
+ with_items: groups['oo_hosts_to_terminate']
- - name: Delete VMs drives
- command: 'virsh -c {{ libvirt_uri }} vol-delete --pool {{ libvirt_storage_pool }} {{ item[0] }}{{ item[1] }}'
- args:
- removes: '{{ libvirt_storage_pool_path }}/{{ item[0] }}{{ item[1] }}'
- with_nested:
- - '{{ list_vms.list_vms }}'
- - [ '_configdrive', '_cloud-init.iso', '.qcow2' ]
- when: item[0]|truncate(cluster_id|length+1, True) == '{{ cluster_id }}-...'