-
Notifications
You must be signed in to change notification settings - Fork 91
/
uninstall.yml
97 lines (82 loc) · 3 KB
/
uninstall.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
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
88
89
90
91
92
93
94
95
96
97
---
- name: Uninstall Lemmy
hosts: all
vars_prompt:
- name: confirm_uninstall
prompt: "Do you really want to uninstall Lemmy? This will delete all data and can not be reverted [yes/no]"
private: false
- name: delete_certs
prompt: "Delete certificates? Select 'no' if you want to reinstall Lemmy [yes/no]"
private: false
- name: stop_disable_nginx
prompt: "Do you want to stop/disable nginx? [yes/no]"
private: false
- name: stop_disable_docker_podman
prompt: "Do you want to stop/disable Docker/podman? [yes/no]"
private: false
tasks:
- name: Inform about cancellation if no confirmation was given
ansible.builtin.debug:
msg: "Uninstall cancelled, doing nothing"
when: not confirm_uninstall | bool
- name: End play if no confirmation was given
ansible.builtin.meta: end_play
when: not confirm_uninstall | bool
- name: Run Debian/Ubuntu specific uninstallation steps
when: ansible_distribution in ['Debian', 'Ubuntu']
block:
- name: Stop docker-compose
community.docker.docker_compose:
project_src: "{{ lemmy_base_dir }}/{{ domain }}"
state: absent
- name: Delete data
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
with_items:
- path: "{{ lemmy_base_dir }}/{{ domain }}"
- path: "/etc/nginx/sites-enabled/{{ domain }}.conf"
- name: Remove certbot cronjob
ansible.builtin.cron:
name: certbot-renew-lemmy
state: absent
- name: Stop and disable Docker
ansible.builtin.systemd:
name: docker.service
state: stopped
enabled: false
when: stop_disable_docker_podman | bool
- name: Run EL specific uninstallation steps
when:
- ansible_distribution in ['AlmaLinux', 'CentOS', 'RedHat', 'Rocky']
- ansible_distribution_major_version | int >= 9
block:
- name: Stop and remove containers
ansible.builtin.command: podman-compose down
args:
chdir: "{{ lemmy_base_dir }}/{{ domain }}"
changed_when: true
- name: Delete Lemmy data
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop:
- path: "{{ lemmy_base_dir }}/{{ domain }}"
- path: "/etc/nginx/conf.d/{{ domain }}.conf"
- name: Stop and disable certbot-renew.timer
ansible.builtin.systemd:
name: certbot-renew.timer
state: stopped
enabled: false
- name: Stop and disable podman
ansible.builtin.systemd:
name: podman.service
state: stopped
enabled: false
when: stop_disable_docker_podman | bool
- name: Stop and disable nginx
ansible.builtin.systemd:
name: nginx.service
state: stopped
enabled: false
when: stop_disable_nginx | bool