-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise10-clean.yaml
More file actions
87 lines (77 loc) · 2.49 KB
/
exercise10-clean.yaml
File metadata and controls
87 lines (77 loc) · 2.49 KB
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
84
85
86
87
- name: Cleaning the exercise10
hosts: localhost
gather_facts: true
vars:
user: "{{ lookup('env', 'USER') }}"
tasks:
- name: Removing VM A
kubernetes.core.k8s:
state: absent
template: "exercise10-create-vm-a.yaml.j2"
register: deletevma
until: deletevma is succeeded
retries: 60
delay: 10
failed_when: deletevma is failed or deletevma.failed
- name: Removing VM B
kubernetes.core.k8s:
state: absent
template: "exercise10-create-vm-b.yaml.j2"
register: deletevmb
until: deletevmb is succeeded
retries: 60
delay: 10
failed_when: deletevma is failed or deletevma.failed
- name: Wait for the Virtual Machine A to be removed
kubernetes.core.k8s_info:
kind: VirtualMachine
namespace: "namespace-{{ user }}"
name: "exercise10-a"
register: cleanvma
retries: 60
delay: 2
until: cleanvma.resources | length == 0
- name: Wait for the Virtual Machine B to be removed
kubernetes.core.k8s_info:
kind: VirtualMachine
namespace: "namespace-{{ user }}"
name: "exercise10-b"
register: cleanvmb
retries: 60
delay: 2
until: cleanvmb.resources | length == 0
- name: Removing NAD
kubernetes.core.k8s:
state: absent
template: "exercise10-create-nad.yaml.j2"
register: deletenad
until: deletenad is succeeded
retries: 60
delay: 10
failed_when: deletenad is failed or deletenad.failed
- name: Get all NetworkAttachmentDefinitions
kubernetes.core.k8s_info:
kind: NetworkAttachmentDefinition
namespace: "namespace-{{ user }}"
register: nad_list
- name: Remove all NetworkAttachmentDefinitions created by the user
kubernetes.core.k8s:
state: absent
kind: NetworkAttachmentDefinition
namespace: "namespace-{{ user }}"
name: "{{ item.metadata.name }}"
with_items: "{{ nad_list.resources }}"
when: nad_list.resources | length > 0
# - name: Get user SSH key
# ansible.builtin.slurp:
# src: "/home/{{ user }}/.ssh/id_rsa.pub"
# register: usersshkey
# - name: Removing the idrsa secret
# kubernetes.core.k8s:
# state: absent
# template: "exercise10-secret.yaml.j2"
# register: secretidrsa
# until: secretidrsa is succeeded
# retries: 60
# delay: 10
# failed_when: secretidrsa is failed or secretidrsa.failed