-
Notifications
You must be signed in to change notification settings - Fork 266
/
pgsql-rm.yml
executable file
·65 lines (63 loc) · 3.06 KB
/
pgsql-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
#!/usr/bin/env ansible-playbook
---
#==============================================================#
# File : pgsql-rm.yml
# Desc : remove pgsql from hosts
# Ctime : 2020-05-12
# Mtime : 2022-12-29
# Path : pgsql-rm.yml
# License : AGPLv3 @ https://pigsty.io/docs/about/license
# Copyright : 2018-2024 Ruohang Feng / Vonng ([email protected])
#==============================================================#
- name: PGSQL REMOVE
become: yes
hosts: all
gather_facts: no
ignore_errors: yes
vars:
pg_uninstall: false # uninstall pg_packages? false by default
#pg_safeguard: false # prevent purging running postgres instance? false by default
#pg_clean: true # remove postgres data? true by default
#pgbackrest_clean: true # remove pgbackrest backup stanza? true by default
roles: [ { role: node_id }, { role: pg_remove } ]
#--------------------------------------------------------------#
# Usage
#--------------------------------------------------------------#
# Remove pgsql cluster `pg-test`
# pgsql-rm.yml -l pg-test # remove cluster `pg-test`
# -e pg_clean=true # remove postgres data by default
# -e pgbackrest_clean=true # remove postgres backup by default (when removing primary)
# -e pg_uninstall=false # do not uninstall pg packages by default, explicit override required
# -e pg_safeguard=false # purge safeguard is not enabled by default, explicit override required
#
# Remove a pgsql replica:
# pgsql-rm.yml -l 10.10.10.13 # remove instance `10.10.10.13` from cluster `pg-test`
# pgsql.yml -l pg-test --tags=pg_service # refresh pg service after cluster shrink
#
#--------------------------------------------------------------#
# Utils
#--------------------------------------------------------------#
#
# bin/pgsql-rm pg-meta # remove pgsql cluster 'pg-meta'
# bin/pgsql-rm pg-test 10.10.10.13 # remove pgsql instance '10.10.10.13' from 'pg-test'
#
#--------------------------------------------------------------#
# Tasks
#--------------------------------------------------------------#
# register : remove registration in prometheus, grafana, nginx
# - prometheus : remove monitor target from prometheus
# - grafana : remove datasource from grafana
# dns : remove pg dns records
# vip : remove pg vip manager
# pg_service : remove service definition from haproxy
# pg_exporter : remove pg_exporter & pgbouncer_exporter
# pgbouncer : remove pgbouncer connection middleware
# postgres : remove postgres instances
# - pg_replica : remove all replicas
# - pg_primary : remove primary instance
# - dcs : remove metadata from dcs
# pg_data : remove postgres data (disable with `pg_clean=false`),
# pgbackrest : remove postgres backup when removing primary (disable with `pgbackrest_clean=false`),
# pg_pkg : remove postgres packages (enable with `pg_uninstall=true`)
#--------------------------------------------------------------#
...