forked from Vonng/pigsty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infra-rm.yml
executable file
·134 lines (119 loc) · 3.88 KB
/
infra-rm.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env ansible-playbook
---
#==============================================================#
# File : infra-rm.yml
# Desc : uninstall pigsty infra module
# Ctime : 2022-02-22
# Mtime : 2022-12-08
# Path : infra-rm.yml
# Author : Ruohang Feng ([email protected])
# License : AGPLv3
#==============================================================#
#---------------------------------------------------------------
# Usage
#---------------------------------------------------------------
# ./infra-rm.yml # remove everything about infra
# ./infra-rm.yml -t service # stop infra services
# ./infra-rm.yml -t data # remove infra data
# ./infra-rm.yml -t package # uninstall infra packages
#---------------------------------------------------------------
#--------------------------------------------------------------#
# Remove Infrastructure
#--------------------------------------------------------------#
- name: INFRA REMOVE
become: yes
hosts: infra
gather_facts: no
ignore_errors: yes
tasks:
#---------------------------------------------
# Stop Service
#---------------------------------------------
- name: stop infra service
systemd: name={{ item }} state=stopped enabled=no daemon_reload=yes
tags: service
with_items:
- alertmanager
- pushgateway
- blackbox_exporter
- prometheus
- loki
- grafana-server
- nginx_exporter
- nginx
- dnsmasq
#---------------------------------------------
# Remove conf
#---------------------------------------------
- name: remove infra conf
file: state=absent path="{{ item }}"
tags: config
with_items:
- /etc/pigsty
- /etc/pki/infra.crt
- /etc/pki/infra.key
- /etc/alertmanager.yml
- /etc/default/alertmanager
- /usr/lib/systemd/system/alertmanager.service
- /etc/blackbox.conf
- /etc/default/blackbox_exporter
- /usr/lib/systemd/system/blackbox_exporter.service
- /etc/default/pushgateway
- /usr/lib/systemd/system/pushgateway.service
- /etc/prometheus
- /etc/default/prometheus
- /usr/lib/systemd/system/prometheus.service
- /etc/loki.yml
- /usr/lib/systemd/system/loki.service
- /etc/grafana
- /usr/lib/systemd/system/grafana.service
- /etc/nginx/
- /etc/default/nginx_exporter
- /usr/lib/systemd/system/nginx.service
- /usr/lib/systemd/system/nginx_exporter.service
- /etc/dnsmasq.conf
- /usr/lib/systemd/system/dnsmasq.service
#---------------------------------------------
# Remove Env
#---------------------------------------------
- name: remove infra env
become: no
file: state=absent path="{{ item }}"
tags: env
with_items:
- '~/.pg_service.conf'
- '~/.servers.json'
- '~/.pgpass'
- '~/.pigsty'
- '~/.pgpass'
#---------------------------------------------
# Remove Infra Data
#---------------------------------------------
- name: remove infra data
file: state=absent path="{{ item }}"
tags: data
with_items:
- "{{ prometheus_data|default('/data/prometheus') }}"
- "{{ loki_data|default('/data/loki') }}"
- "{{ nginx_home|default('/www') }}"
- /var/lib/grafana
- /etc/hosts.d
#---------------------------------------------
# Uninstall Packages
#---------------------------------------------
- name: uninstall infra packages
yum: name={{ item }} state=removed
tags: package
with_items:
- alertmanager
- pushgateway
- blackbox_exporter
- prometheus2
- loki
- grafana
- nginx_exporter
- nginx
- dnsmasq
- mcli
- logcli
...