Skip to content

Commit 8b002d1

Browse files
committed
1 parent 709e934 commit 8b002d1

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

roles/patroni/templates/patroni.yml.j2

+14-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,20 @@ bootstrap:
5959
synchronous_mode: {{ synchronous_mode |string |d(false, true) |lower }}
6060
synchronous_mode_strict: {{ synchronous_mode_strict |string |d(false, true) |lower }}
6161
synchronous_node_count: {{ synchronous_node_count |d(1, true) |int }}
62-
# standby_cluster:
63-
# host: 127.0.0.1
64-
# port: 1111
65-
# primary_slot_name: patroni
62+
{% if patroni_standby_cluster.host is defined and patroni_standby_cluster.host | length > 0 %}
63+
standby_cluster:
64+
host: {{ patroni_standby_cluster.host }}
65+
port: {{ patroni_standby_cluster.port }}
66+
{% if patroni_standby_cluster.primary_slot_name is defined and patroni_standby_cluster.primary_slot_name | length > 0 %}
67+
primary_slot_name: {{ patroni_standby_cluster.primary_slot_name }}
68+
{% endif %}
69+
{% if patroni_standby_cluster.restore_command is defined and patroni_standby_cluster.restore_command | length > 0 %}
70+
restore_command: {{ patroni_standby_cluster.restore_command }}
71+
{% endif %}
72+
{% if patroni_standby_cluster.recovery_min_apply_delay is defined and patroni_standby_cluster.recovery_min_apply_delay | length > 0 %}
73+
recovery_min_apply_delay: {{ patroni_standby_cluster.recovery_min_apply_delay }}
74+
{% endif %}
75+
{% endif %}
6676
postgresql:
6777
use_pg_rewind: {{ patroni_postgresql_use_pg_rewind |string |d(false, true) |lower }}
6878
use_slots: true

vars/main.yml

+8
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,14 @@ patroni_retry_timeout: 10
218218
patroni_maximum_lag_on_failover: 1048576
219219
patroni_master_start_timeout: 300
220220

221+
# https://patroni.readthedocs.io/en/latest/replica_bootstrap.html#standby-cluster
222+
patroni_standby_cluster:
223+
host: "" # an address of remote master
224+
port: "5432" # a port of remote master
225+
# primary_slot_name: "" # which slot on the remote master to use for replication (optional)
226+
# restore_command: "" # command to restore WAL records from the remote master to standby leader (optional)
227+
# recovery_min_apply_delay: "" # how long to wait before actually apply WAL records on a standby leader (optional)
228+
221229
patroni_log_destination: stderr # or 'logfile'
222230
# if patroni_log_destination: logfile
223231
patroni_log_dir: /var/log/patroni

0 commit comments

Comments
 (0)