-
Notifications
You must be signed in to change notification settings - Fork 76
/
99_cleanup.yml
53 lines (48 loc) · 1.59 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
---
- name: Cleanup playbook
hosts: vm_host
vars_files:
- vars/k8s_cluster.yml
tasks:
- name: Set home directory
ansible.builtin.set_fact:
home_dir: "{{ ansible_env.HOME }}"
- name: Destroy cluster VM
community.general.terraform:
force_init: true
project_path: "{{ workspace_directory.base_path }}/clusters/{{ k8s.cluster_name | default('k8s-test', true) }}"
state: absent
variables:
pool_name: "{{ k8s.cluster_name | default('k8s-test', true) }}"
network_name: "{{ k8s.cluster_name | default('k8s-test', true) }}"
become: true
- name: Ensure images are deleted
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /tmp/OS-GenericCloud.qcow2
become: true
- name: Delete all created paths
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ workspace_directory.base_path }}/clusters/{{ k8s.cluster_name | default('k8s-test', true) }}"
become: true
- name: Cleanup local DNS config
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- /etc/NetworkManager/dnsmasq.d/{{ k8s.cluster_name | default('k8s-test', true) }}-libvirt_dnsmasq.conf
- /etc/NetworkManager/conf.d/{{ k8s.cluster_name | default('k8s-test', true) }}-localdns.conf
become: true
- name: Restart NetworkManager and libvirtd
ansible.builtin.service:
name: "{{ item }}"
state: restarted
loop:
- virtqemud
- NetworkManager
become: true