mirror of
https://gitea.0xace.cc/ansible-galaxy/patroni.git
synced 2025-06-29 02:53:07 +00:00
refactor and fix pitr
This commit is contained in:
@ -1,11 +1,4 @@
|
||||
- name: Add WAL-G to patroni_create_replica_methods
|
||||
set_fact:
|
||||
patroni_create_replica_methods: "{{ patroni_create_replica_methods + [ 'wal_g' ] }}"
|
||||
when: patroni_wal_g_install
|
||||
|
||||
- name: Include WAL-G role
|
||||
ansible.builtin.include_role:
|
||||
name: wal-g-pg
|
||||
vars:
|
||||
wal_g_pg: yes
|
||||
when: patroni_wal_g_install
|
||||
|
@ -1,11 +1,4 @@
|
||||
- name: Add WAL-G to patroni_create_replica_methods
|
||||
set_fact:
|
||||
patroni_create_replica_methods: "{{ patroni_create_replica_methods + [ 'wal_g' ] }}"
|
||||
when: patroni_wal_g_install
|
||||
|
||||
- name: Include WAL-G role
|
||||
ansible.builtin.include_role:
|
||||
name: wal-g-pg
|
||||
vars:
|
||||
wal_g_pg: yes
|
||||
when: patroni_wal_g_install
|
||||
|
@ -31,6 +31,13 @@
|
||||
path: "/etc/patroni/{{ patroni_config_name }}"
|
||||
register: patroni_config_file_exists_result
|
||||
|
||||
- name: Add WAL-G to patroni_create_replica_methods
|
||||
set_fact:
|
||||
patroni_create_replica_methods: "{{ patroni_create_replica_methods + [ 'wal_g' ] }}"
|
||||
when:
|
||||
- patroni_wal_g_install
|
||||
- patroni_wal_g_backup_enable
|
||||
|
||||
- name: Propagate Patroni config
|
||||
copy:
|
||||
content: "{{ patroni_config_combined | to_nice_yaml }}"
|
||||
|
@ -71,6 +71,10 @@
|
||||
register: patroni_enable_and_start
|
||||
tags: patroni, patroni_start
|
||||
|
||||
- name: Include reset {{ patroni_superuser_username }} password after restore
|
||||
include_tasks: reset-password-after-restore.yaml
|
||||
when: patroni_wal_g_restore_from_backup
|
||||
|
||||
- name: Dynamic Patroni configuration
|
||||
include_tasks: dynamic_config.yaml
|
||||
tags: patroni_dynamic_configure
|
||||
|
41
tasks/reset-password-after-restore.yaml
Normal file
41
tasks/reset-password-after-restore.yaml
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
- name: Reset {{ patroni_superuser_username }} password after restore
|
||||
block:
|
||||
- name: Wait for Patroni leader
|
||||
vars:
|
||||
_query: 'json.members[].role'
|
||||
ansible.builtin.uri:
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}/cluster"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
- 200
|
||||
- 503
|
||||
register: patroni_role
|
||||
until: patroni_role | json_query(_query) | regex_findall('leader') | count > 0
|
||||
retries: 100
|
||||
delay: 10
|
||||
|
||||
- name: Get Patroni nodes roles
|
||||
ansible.builtin.uri:
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
- 200
|
||||
- 503
|
||||
register: patroni_role
|
||||
|
||||
- name: Set fact about roles
|
||||
set_fact:
|
||||
role: "{{ patroni_role.json.role }}"
|
||||
|
||||
- name: Reset {{ patroni_superuser_username }} password after restore
|
||||
become_user: "{{ postgresql_user }}"
|
||||
community.postgresql.postgresql_query:
|
||||
db: "{{ patroni_superuser_db }}"
|
||||
query: ALTER USER {{ patroni_superuser_username }} with password '{{ patroni_superuser_password }}';
|
||||
when:
|
||||
- "hostvars[inventory_hostname]['role'] == 'master'"
|
||||
rescue:
|
||||
- include_tasks: /reset-password-after-restore.yaml
|
Reference in New Issue
Block a user