mirror of
https://gitea.0xace.cc/ansible-galaxy/patroni.git
synced 2024-11-24 23:56:39 +00:00
fix backup/restore and update vars for patroni rest
This commit is contained in:
parent
7bf4ad8d17
commit
c8d358bbe3
@ -48,6 +48,9 @@ patroni_dcs_type: "consul"
|
||||
|
||||
## WAL-G backup and restore options
|
||||
patroni_wal_g_install: false
|
||||
patroni_wal_g_backup_enable: false
|
||||
patroni_wal_g_backup_permanent_enable: false
|
||||
patroni_wal_g_backup_retention_enable: false
|
||||
patroni_wal_g_restore_from_backup: false
|
||||
patroni_wal_g_pitr: ""
|
||||
patroni_wal_g_restore_backup_name: "LATEST"
|
||||
@ -79,7 +82,8 @@ patroni_synchronous_mode: false # or 'true' for enable synchronous database rep
|
||||
patroni_synchronous_mode_strict: false # if 'true' then block all client writes to the master, when a synchronous replica is not available
|
||||
patroni_synchronous_node_count: 2 # number of synchronous standby databases
|
||||
|
||||
patroni_postgresql_port: "5432"
|
||||
patroni_postgresql_listen_address: "0.0.0.0"
|
||||
patroni_postgresql_listen_port: "5432"
|
||||
patroni_postgresql_encoding: "UTF8" # for bootstrap only (initdb)
|
||||
patroni_postgresql_locale: "en_US.UTF-8" # for bootstrap only (initdb)
|
||||
patroni_postgresql_data_checksums: true # for bootstrap only (initdb)
|
||||
@ -115,8 +119,8 @@ patroni_postgresql_dynamic_parameters: {}
|
||||
patroni_postgresql_backup_parameters:
|
||||
postgresql:
|
||||
parameters:
|
||||
archive_command: "{{ patroni_postgresql_archive_command if patroni_wal_g_backup_enable else 'cd .' }}"
|
||||
restore_command: "{{ patroni_postgresql_restore_command if patroni_wal_g_backup_enable else 'cd .' }}"
|
||||
archive_command: "{{ patroni_postgresql_archive_command if patroni_wal_g_install else 'cd .' }}"
|
||||
restore_command: "{{ patroni_postgresql_restore_command if (patroni_wal_g_install or patroni_wal_g_restore_from_backup) else 'cd .' }}"
|
||||
|
||||
# postgresql parameters to bootstrap dcs (are parameters for example)
|
||||
patroni_postgresql_max_connections: "1000"
|
||||
|
@ -36,7 +36,6 @@
|
||||
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:
|
||||
|
@ -19,7 +19,7 @@
|
||||
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"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}/cluster"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
- 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 }}"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
- name: Apply dynamic configuration parameters for Patroni
|
||||
ansible.builtin.uri:
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}/config"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}/config"
|
||||
user: "{{ patroni_restapi_username }}"
|
||||
password: "{{ patroni_restapi_password }}"
|
||||
method: PATCH
|
||||
|
@ -5,7 +5,7 @@
|
||||
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"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}/cluster"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
- 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 }}"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
@ -31,11 +31,11 @@
|
||||
role: "{{ patroni_role.json.role }}"
|
||||
|
||||
- name: Reset {{ patroni_superuser_username }} password after restore
|
||||
become_user: "{{ postgresql_user }}"
|
||||
become_user: "{{ patroni_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
|
||||
- include_tasks: reset-password-after-restore.yaml
|
||||
|
@ -5,7 +5,7 @@
|
||||
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"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}/cluster"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
- 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 }}"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}"
|
||||
method: GET
|
||||
body_format: json
|
||||
status_code:
|
||||
@ -33,7 +33,7 @@
|
||||
- name: Restart if pending restart
|
||||
throttle: 1
|
||||
ansible.builtin.uri:
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ patroni_restapi_listen_port }}/restart"
|
||||
url: "{{ 'https://' if patroni_ssl else 'http://' }}{{ patroni_restapi_listen_address }}:{{ patroni_restapi_listen_port }}/restart"
|
||||
user: "{{ patroni_restapi_username }}"
|
||||
password: "{{ patroni_restapi_password }}"
|
||||
method: POST
|
||||
|
@ -125,8 +125,8 @@ bootstrap:
|
||||
- host replication replicator 0.0.0.0/0 {{ patroni_postgresql_password_encryption_algorithm }}
|
||||
|
||||
postgresql:
|
||||
listen: 0.0.0.0:{{ patroni_postgresql_port }}
|
||||
connect_address: {{ hostvars[inventory_hostname]['ansible_host'] }}:{{ patroni_postgresql_port }}
|
||||
listen: {{ patroni_postgresql_listen_address }}:{{ patroni_postgresql_listen_port }}
|
||||
connect_address: {{ hostvars[inventory_hostname]['ansible_host'] }}:{{ patroni_postgresql_listen_port }}
|
||||
use_unix_socket: true
|
||||
data_dir: {{ patroni_postgresql_home_dir }}/{{ patroni_postgresql_major_version }}/{{ patroni_postgresql_cluster_name }}
|
||||
bin_dir: {{ patroni_postgresql_bin_dir }}
|
||||
|
Loading…
Reference in New Issue
Block a user