Newer
Older
#!/usr/bin/env ansible-playbook
---
- name: POSTGRESQL SWITCH CURRENT STANDBY TO PRIMARY
hosts: postgres_standby
tasks:
- name: fail if node status if not standby
msg: Current status {{ rephacheck['stdout'] }} must be standby.
when: rephacheck['stdout'] != "standby"
- name: check if node is currently in standby
ansible.builtin.command:
cmd: repmgr standby switchover -f /etc/postgresql/13/main/repmgr.conf --siblings-follow --dry-run
- name: switch standby node to primary
ansible.builtin.command:
cmd: repmgr standby switchover -f /etc/postgresql/13/main/repmgr.conf --siblings-follow
when:
- standby_dry_run is succeeded
- rephacheck['stdout'] == "standby"