From 8b002d1fedab29ee4987b9fef63d35fdabaaecd9 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik Date: Tue, 24 Aug 2021 01:51:32 +0600 Subject: [PATCH] Add patroni_standby_cluster Doc: https://patroni.readthedocs.io/en/latest/replica_bootstrap.html#standby-cluster --- roles/patroni/templates/patroni.yml.j2 | 18 ++++++++++++++---- vars/main.yml | 8 ++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/roles/patroni/templates/patroni.yml.j2 b/roles/patroni/templates/patroni.yml.j2 index 406297040..a585b62fa 100644 --- a/roles/patroni/templates/patroni.yml.j2 +++ b/roles/patroni/templates/patroni.yml.j2 @@ -59,10 +59,20 @@ bootstrap: synchronous_mode: {{ synchronous_mode |string |d(false, true) |lower }} synchronous_mode_strict: {{ synchronous_mode_strict |string |d(false, true) |lower }} synchronous_node_count: {{ synchronous_node_count |d(1, true) |int }} - # standby_cluster: - # host: 127.0.0.1 - # port: 1111 - # primary_slot_name: patroni + {% if patroni_standby_cluster.host is defined and patroni_standby_cluster.host | length > 0 %} + standby_cluster: + host: {{ patroni_standby_cluster.host }} + port: {{ patroni_standby_cluster.port }} + {% if patroni_standby_cluster.primary_slot_name is defined and patroni_standby_cluster.primary_slot_name | length > 0 %} + primary_slot_name: {{ patroni_standby_cluster.primary_slot_name }} + {% endif %} + {% if patroni_standby_cluster.restore_command is defined and patroni_standby_cluster.restore_command | length > 0 %} + restore_command: {{ patroni_standby_cluster.restore_command }} + {% endif %} + {% if patroni_standby_cluster.recovery_min_apply_delay is defined and patroni_standby_cluster.recovery_min_apply_delay | length > 0 %} + recovery_min_apply_delay: {{ patroni_standby_cluster.recovery_min_apply_delay }} + {% endif %} + {% endif %} postgresql: use_pg_rewind: {{ patroni_postgresql_use_pg_rewind |string |d(false, true) |lower }} use_slots: true diff --git a/vars/main.yml b/vars/main.yml index 8965ab752..244868796 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -218,6 +218,14 @@ patroni_retry_timeout: 10 patroni_maximum_lag_on_failover: 1048576 patroni_master_start_timeout: 300 +# https://patroni.readthedocs.io/en/latest/replica_bootstrap.html#standby-cluster +patroni_standby_cluster: + host: "" # an address of remote master + port: "5432" # a port of remote master +# primary_slot_name: "" # which slot on the remote master to use for replication (optional) +# restore_command: "" # command to restore WAL records from the remote master to standby leader (optional) +# recovery_min_apply_delay: "" # how long to wait before actually apply WAL records on a standby leader (optional) + patroni_log_destination: stderr # or 'logfile' # if patroni_log_destination: logfile patroni_log_dir: /var/log/patroni