forked from vitabaks/autobase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove_cluster.yml
83 lines (80 loc) · 2.6 KB
/
remove_cluster.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
---
- name: remove_cluster.yml | Remove PostgreSQL HA Cluster
hosts: postgres_cluster
become: true
pre_tasks:
- name: "Set variable: ansible_python_interpreter"
ansible.builtin.set_fact:
ansible_python_interpreter: "/usr/bin/env python3"
when: "'python3' not in (ansible_python_interpreter | default(''))"
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
- name: Include OS-specific variables
ansible.builtin.include_vars: "vars/{{ ansible_os_family }}.yml"
tasks:
- block:
- name: Stop Patroni service
ansible.builtin.service:
name: patroni
state: stopped
enabled: false
- name: Delete PostgreSQL database content
ansible.builtin.file:
path: "{{ postgresql_data_dir }}"
state: absent
when: remove_postgres | default(false) | bool
ignore_errors: true
- block:
- name: Delete PgBackRest repository
ansible.builtin.file:
# path: pgbackrest_conf global repo1-path
path: /var/lib/pgbackrest
state: absent
- name: Delete PgBackRest cron
ansible.builtin.file:
path: /etc/cron.d/pgbackrest
state: absent
when: pgbackrest_install | default(false) | bool
ignore_errors: true
- name: remove_cluster.yml | Consul Cluster Play
hosts: consul_instances
become: true
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tasks:
- block:
- name: Stop Consul service
ansible.builtin.service:
name: consul
state: stopped
enabled: false
- name: Delete Consul content
ansible.builtin.file:
path: "{{ consul_data_path }}"
state: absent
- name: Delete Consul serivce
ansible.builtin.file:
path: /lib/systemd/system/consul.service
state: absent
when: remove_consul | default(false) | bool
ignore_errors: true
- name: remove_cluster.yml | Etcd Cluster Play
hosts: etcd_cluster
become: true
pre_tasks:
- name: Include main variables
ansible.builtin.include_vars: "vars/main.yml"
tasks:
- block:
- name: Stop Etcd service
ansible.builtin.service:
name: etcd
state: stopped
enabled: false
- name: Delete Etcd content
ansible.builtin.file:
path: "{{ etcd_data_dir }}/member"
state: absent
when: remove_etcd | default(false) | bool
ignore_errors: true