-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_worker_okd_vm.yml
34 lines (34 loc) · 1.02 KB
/
delete_worker_okd_vm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
- name: Delete worker {{ item.index }} virtual machine
vars:
vm_name: "compute-{{ item.index }}.sandbox.okd.local"
ip: "{{ item.ip }}"
block:
- name: Delete {{ vm_name }} virtual machine data
file:
path: "/home/{{ ansible_user_id }}/.okd/vms/{{ vm_name }}"
state: absent
- name: List virtual machines
virt:
command: list_vms
uri: "qemu:///session"
register: vms
- debug:
msg: "{{ vms }}"
- name: Destroy {{ vm_name }} virtual machine
virt:
command: destroy
name: "{{ vm_name }}"
uri: "qemu:///session"
when: vm_name in vms.list_vms
- name: Undefine {{ vm_name }} virtual machine
virt:
command: undefine
name: "{{ vm_name }}"
uri: "qemu:///session"
when: vm_name in vms.list_vms
- name: Remove {{ vm_name }} virtual machine host from known_hosts
lineinfile:
path: "/home/{{ ansible_user_id }}/.ssh/known_hosts"
state: absent
regexp: '^.*{{ ip }}.*$'