-
Notifications
You must be signed in to change notification settings - Fork 40
/
99_cleanup.yml
55 lines (51 loc) · 1.64 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
---
- name: Cleanup playbook
hosts: vm_host
vars_files:
- vars/infra_vars.yml
- vars/cluster_vars.yml
tasks:
- name: Set home directory as fact
ansible.builtin.set_fact:
home_dir: "{{ ansible_env.HOME }}"
- name: Destroy support VM
community.general.terraform:
force_init: true
project_path: "{{ workspace_directory.base_path }}/{{ cluster.name }}/terraform/{{ item }}"
state: absent
variables:
sshkey: "{{ playbook_dir }}"
loop:
- bastion
- loadbalancer
become: true
- name: Destroy cluster VM
community.general.terraform:
force_init: true
project_path: "{{ workspace_directory.base_path }}/{{ cluster.name }}/terraform/{{ item }}"
state: absent
loop:
- bootstrap
- workers
- masters
- sno
become: true
- name: Use TF project to ensure pool and network are removed
community.general.terraform:
project_path: "{{ workspace_directory.base_path }}/{{ cluster.name }}/terraform/libvirt-resources"
variables:
domain: "{{ domain }}"
network_cidr: ' ["{{ network_cidr }}"]'
cluster_name: "{{ cluster.name }}"
force_init: true
state: absent
become: true
- name: Delete all created paths
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ workspace_directory.base_path }}/{{ cluster.name }}"
- /etc/NetworkManager/conf.d/{{ cluster.name }}-localdns.conf
- /etc/NetworkManager/dnsmasq.d/{{ cluster.name }}-libvirt_dnsmasq.conf
become: true