Newer
Older
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
---
- name: stop master node
hosts: postgres[0]
tasks:
- name: stop postgresql
service:
name: postgresql@11-main
state: stopped
- name: pause for 45 seconds
hosts: localhost
tasks:
- pause:
seconds: 45
- name: set correct host to correct groups
hosts: postgres
tasks:
- name: add db0 to fenced group
add_host:
name: "{{ groups['postgres'][0] }}"
groups: [ 'postgres_fenced', 'postgres_standby' ]
- name: add db1 to primary group
add_host:
name: "{{ groups['postgres'][1] }}"
groups: postgres_primary
# db0 is now fenced, import playbook to switch it back to standby
- import_playbook: ../../playbooks/postgres-maintenance/rephacheck_status.yml
- import_playbook: ../../playbooks/postgres-maintenance/fenced_to_standby.yml
- name: pause for 45 seconds
hosts: localhost
tasks:
- pause:
seconds: 45
# db0 is now standby, import playbook to switch it back as primary
- import_playbook: ../../playbooks/postgres-maintenance/rephacheck_status.yml
- import_playbook: ../../playbooks/postgres-maintenance/standby_to_primary.yml
- name: pause for 45 seconds
hosts: localhost
tasks:
- pause:
seconds: 45
# db0 is now primary, restart repmgrd
- import_playbook: ../../playbooks/postgres-maintenance/rephacheck_status.yml
- import_playbook: ../../playbooks/postgres-maintenance/restart_repmgrd.yml
...