summaryrefslogtreecommitdiffstats
path: root/playbooks/libvirt/openshift-cluster/terminate.yml
diff options
context:
space:
mode:
authorThomas Wiest <twiest@users.noreply.github.com>2015-04-10 11:33:25 -0400
committerThomas Wiest <twiest@users.noreply.github.com>2015-04-10 11:33:25 -0400
commitdd0f997a77fa88291bbd0ec3d59ba0ad369d9fec (patch)
tree5c5aad99026f1b1d289d0b5597fb5f596b4906c7 /playbooks/libvirt/openshift-cluster/terminate.yml
parent914b4c41d4a5f25f9ea850d21a50926148ae4bf1 (diff)
parent9fbec064d28a72963b1566258b4bcabcd63b2c23 (diff)
downloadopenshift-dd0f997a77fa88291bbd0ec3d59ba0ad369d9fec.tar.gz
openshift-dd0f997a77fa88291bbd0ec3d59ba0ad369d9fec.tar.bz2
openshift-dd0f997a77fa88291bbd0ec3d59ba0ad369d9fec.tar.xz
openshift-dd0f997a77fa88291bbd0ec3d59ba0ad369d9fec.zip
Merge pull request #141 from lhuard1A/virt
Add libvirt as a provider for openshift-ansible
Diffstat (limited to 'playbooks/libvirt/openshift-cluster/terminate.yml')
-rw-r--r--playbooks/libvirt/openshift-cluster/terminate.yml41
1 files changed, 41 insertions, 0 deletions
diff --git a/playbooks/libvirt/openshift-cluster/terminate.yml b/playbooks/libvirt/openshift-cluster/terminate.yml
new file mode 100644
index 000000000..c609169d3
--- /dev/null
+++ b/playbooks/libvirt/openshift-cluster/terminate.yml
@@ -0,0 +1,41 @@
+- name: Terminate instance(s)
+ hosts: localhost
+ connection: local
+ gather_facts: no
+
+ vars:
+ libvirt_storage_pool_path: "{{ lookup('env','HOME') }}/libvirt-storage-pool-openshift"
+ libvirt_storage_pool: 'openshift'
+ libvirt_uri: 'qemu:///system'
+
+ tasks:
+ - name: List VMs
+ virt:
+ command: list_vms
+ register: list_vms
+
+ - 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 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: 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 }}-...'