Skip to content

Commit

Permalink
Add patroni_replicatefrom variable for cascading replication (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Feb 3, 2025
1 parent 026ec78 commit 28f7557
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 6 additions & 5 deletions automation/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
# "postgresql_exists=true" if PostgreSQL is already exists and running
# "hostname=" variable is optional (used to change the server name)
# "new_node=true" to add a new server to an existing cluster using the add_pgnode.yml playbook
# balancer_tags="key=value" the Balancer tags for the /replica, /sync, /async endpoints. Must match 'patroni_tags'.
# patroni_tags="key=value" the Patroni tags in "key=value" format separated by commas.
# balancer_tags="key=value" the Balancer tags for the /replica, /sync, /async endpoints. Add the tag to the 'patroni_tags' variable first.
# patroni_replicatefrom="<hostname>" the Patroni node to replicate from (cascading replication).

# if dcs_exists: false and dcs_type: "etcd"
[etcd_cluster] # recommendation: 3, or 5-7 nodes
Expand All @@ -28,8 +29,8 @@
#10.128.64.140 # balancer_tags="datacenter=dc1"
#10.128.64.142 # balancer_tags="datacenter=dc1"
#10.128.64.143 # balancer_tags="datacenter=dc1"
#10.128.64.144 balancer_tags="datacenter=dc2"
#10.128.64.145 balancer_tags="datacenter=dc2" new_node=true
#10.128.64.144 # balancer_tags="datacenter=dc2"
#10.128.64.145 # balancer_tags="datacenter=dc2" new_node=true

# PostgreSQL nodes
[master]
Expand All @@ -38,8 +39,8 @@
[replica]
#10.128.64.142 hostname=pgnode02 postgresql_exists=false # patroni_tags="datacenter=dc1"
#10.128.64.143 hostname=pgnode03 postgresql_exists=false # patroni_tags="datacenter=dc1"
#10.128.64.144 hostname=pgnode04 postgresql_exists=false patroni_tags="datacenter=dc2"
#10.128.64.145 hostname=pgnode04 postgresql_exists=false patroni_tags="datacenter=dc2" new_node=true
#10.128.64.144 hostname=pgnode04 postgresql_exists=false # patroni_tags="datacenter=dc2" patroni_replicatefrom="pgnode03"
#10.128.64.145 hostname=pgnode04 postgresql_exists=false # patroni_tags="datacenter=dc2" new_node=true

[postgres_cluster:children]
master
Expand Down
7 changes: 3 additions & 4 deletions automation/roles/patroni/templates/patroni.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ tags:
{% if 'clonefrom=' not in normalized_tags %}
clonefrom: false
{% endif %}

# specify a node to replicate from (cascading replication)
# replicatefrom: (node name)

{% if 'replicatefrom=' not in normalized_tags and patroni_replicatefrom | default('') | length > 0 %}
replicatefrom: {{ patroni_replicatefrom | default('') }}
{% endif %}

0 comments on commit 28f7557

Please sign in to comment.