-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall-gitlab.yml
93 lines (80 loc) · 3.23 KB
/
uninstall-gitlab.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
---
# See the documented procedure:
# <https://docs.gitlab.com/omnibus/installation/#uninstall-the-linux-package-omnibus>
- name: GitLab | is completely uninstalled
hosts: gitlab_hosts
# vars:
# gitlab_destroy_data: false
tasks:
- name: GitLab uninstall | processes are stopped
become: true
ansible.builtin.command:
cmd: gitlab-ctl stop
tags: [ stop-processes ]
- name: GitLab uninstall | for processes to stop, a delay is observed
ansible.builtin.wait_for:
timeout: 5 # seconds
- name: GitLab uninstall | data is destroyed
when: gitlab_destroy_data | default(false) | bool
tags: [ destroy-data ]
block:
- name: GitLab uninstall | runsvdir is stopped and disabled
become: true
ansible.builtin.systemd_service:
# KLUDGE: this one should be able to run when
# gitlab_destroy_data=false, but unfortunately the `yum install
# gitlab-XX` does not properly restarts the
# `gitlab-runsvdir.service` systemd unit and the handler for root
# API key creation fails. So, in order to be able to re-install
# after this uninstall has run, we just don't stop this service.
name: gitlab-runsvdir
enabled: false
state: stopped
tags: [ stop-process-supervisor ]
- name: GitLab uninstall | for runsvdir to stop, a delay is observed
ansible.builtin.wait_for:
timeout: 5 # seconds
- name: GitLab uninstall | the 'gitlab-runsvdir' unit file is absent
become: true
ansible.builtin.file:
path: /usr/lib/systemd/system/gitlab-runsvdir.service
state: absent
tags: [ remove-unit-file ]
- name: GitLab uninstall | the systemd daemon is reloaded
become: true
ansible.builtin.systemd_service:
daemon_reload: true
tags: [ reload-systemd ]
- name: GitLab uninstall | the "failed" state of all systemd units is reset
become: true
ansible.builtin.command: # noqa: command-instead-of-module
cmd: systemctl reset-failed
tags: [ reset-systemd-unit-failed-state ]
- name: GitLab uninstall | the process supervisor is uninstalled
become: true
ansible.builtin.command:
cmd: gitlab-ctl uninstall
tags: [ uninstall-process-supervisor ]
- name: GitLab uninstall | data is destroyed
when: gitlab_destroy_data | default(false) | bool
tags: [ destroy-data ]
block:
- name: GitLab uninstall | all gitlab data is deleted
become: true
ansible.builtin.command: gitlab-ctl cleanse
- name: GitLab uninstall | user accounts are removed
become: true
ansible.builtin.command:
cmd: gitlab-ctl remove-accounts
tags: [ remove-accounts ]
- name: GitLab uninstall | the base directory is removed
become: true
ansible.builtin.file:
path: /opt/gitlab
state: absent
- name: GitLab uninstall | the all-in-one package is removed
become: true
ansible.builtin.package:
name: gitlab-ce
state: absent
tags: [ uninstall-package ]