forked from kubealex/libvirt-k8s-provisioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
99_cleanup.yml
83 lines (76 loc) · 2.07 KB
/
99_cleanup.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
- name: Cleanup playbook
hosts: vm_host
vars_files:
- vars/k8s_cluster.yml
become: true
tasks:
- name: Destroy cluster VM
community.general.terraform:
force_init: true
project_path: "clusters/{{ k8s.cluster_name }}/{{ item }}"
state: absent
loop:
- workers
- masters
- loadbalancer
- nfs
when:
- not rook_ceph.install_rook
- k8s.control_plane.vms > 1
- name: Destroy cluster VM
community.general.terraform:
force_init: true
project_path: "clusters/{{ k8s.cluster_name }}/{{ item }}"
state: absent
loop:
- workers
- masters
- nfs
when:
- not rook_ceph.install_rook
- k8s.control_plane.vms == 1
- name: Destroy cluster VM
community.general.terraform:
force_init: true
project_path: "clusters/{{ k8s.cluster_name }}/{{ item }}"
state: absent
loop:
- workers-rook
- workers
- masters
- loadbalancer
when: rook_ceph.install_rook
- name: Destroy libvirt pool and network
community.general.terraform:
force_init: true
project_path: "clusters/{{ k8s.cluster_name }}/libvirt-resources"
state: absent
- name: Ensure images are deleted
file:
path: "{{ item }}"
state: absent
loop:
- /tmp/OS-GenericCloud.qcow2
- name: Delete all created paths - root
become: true
file:
path: "{{ item }}"
state: absent
loop:
- clusters/{{ k8s.cluster_name }}
- "{{ k8s.cluster_name }}-inventory-k8s"
- name: Cleanup local DNS config
file:
path: "{{ item }}"
state: absent
loop:
- /etc/NetworkManager/dnsmasq.d/{{ k8s.cluster_name }}-libvirt_dnsmasq.conf
- /etc/NetworkManager/conf.d/{{ k8s.cluster_name }}-localdns.conf
- name: Restart NetworkManager and libvirtd
service:
name: "{{ item }}"
state: restarted
loop:
- libvirtd
- NetworkManager