-
Notifications
You must be signed in to change notification settings - Fork 3
/
crictl-rmp.pb
54 lines (52 loc) · 1.52 KB
/
crictl-rmp.pb
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
---
- hosts: all
tasks:
- name: "get ready (running) pods"
shell: "crictl pods --state ready | awk '{print $1}' | tail -n+2"
become: true
failed_when: pods_running.stderr_lines.length > 1
register: pods_running
tags:
- get
- crictl
- name: "stop ready pods"
shell: "crictl stopp {{ pods_running.stdout_lines|join(' ') }}"
when: pods_running.stdout_lines|length > 0
become: true
tags:
- stop
- crictl
- name: "get all pods with 'crictl pods'"
shell: "crictl pods --no-trunc | awk '{print $1}' | tail -n+2"
failed_when: pods_all.stderr_lines.length > 1
become: true
register: pods_all
tags:
- get
- crictl
- name: "remove all pods"
shell: "crictl rmp {{ pods_all.stdout_lines|join(' ') }}"
when: pods_all.stdout_lines|length > 0
become: true
tags:
- stop
- crictl
- name: list relevant units
shell: "systemctl list-units -t mount -t scope | grep -e '\\(run-k3s-containerd-io.*mount\\|cri-containerd-.*scope\\)' | awk '{print $1}'"
register: systemd_units
tags:
- get
- systemd
- name: stop systemd units
systemd:
name: "{{item}}"
state: stopped
# finger cross this deletes scopes first
loop: "{{scopes + mounts}}"
vars:
scopes: "{{ systemd_units.stdout_lines|select('search', '.scope') }}"
mounts: "{{ systemd_units.stdout_lines|select('search', '.mount') }}"
become: true
tags:
- stop
- systemd