-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_stop_and_remove.yml
More file actions
46 lines (42 loc) · 1.3 KB
/
docker_stop_and_remove.yml
File metadata and controls
46 lines (42 loc) · 1.3 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
- name: Stop and remove the running containers for frontend, backend and MongoDB, also remove the images
hosts: all
become: true
tasks:
- name: Set default values if variables are not defined
set_fact:
BACKEND_IMAGE: "{{ BACKEND_IMAGE | default('ghcr.io/paulscherrerinstitute/data_board_backend') }}"
FRONTEND_IMAGE: "{{ FRONTEND_IMAGE | default('ghcr.io/paulscherrerinstitute/data_board_frontend') }}"
MONGO_IMAGE: "{{ MONGO_IMAGE | default('mongo') }}"
- name: Stop containers gracefully
docker_container:
name: "{{ item }}"
state: stopped
loop:
- data_board_frontend
- data_board_backend
- data_board_mongo
ignore_errors: yes
- name: Remove containers
docker_container:
name: "{{ item }}"
state: absent
loop:
- data_board_frontend
- data_board_backend
- data_board_mongo
ignore_errors: yes
- name: Remove network
docker_network:
name: data_board_network
state: absent
force: yes
ignore_errors: yes
- name: Remove images
docker_image:
name: "{{ item }}"
state: absent
loop:
- "{{ FRONTEND_IMAGE }}"
- "{{ BACKEND_IMAGE }}"
- "{{ MONGO_IMAGE }}"
ignore_errors: yes