From 7d19b6e57ea13dcfbd0c8a26ffa2e9bc9d810e04 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik Date: Mon, 11 Dec 2023 14:33:57 +0300 Subject: [PATCH 1/2] Fix add_pgnode.yml: Clear the data directory for the new node --- roles/patroni/tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/roles/patroni/tasks/main.yml b/roles/patroni/tasks/main.yml index f936129eb..6534588f6 100644 --- a/roles/patroni/tasks/main.yml +++ b/roles/patroni/tasks/main.yml @@ -455,6 +455,8 @@ postgresql_packages|join(" ") is not search("postgrespro")) and not postgresql_conf_file.stat.exists + # When performing PITR, we do not clear the directory if pgbackrest is used + # to be able to use the '--delta restore' option. - name: Prepare PostgreSQL | make sure the data directory "{{ postgresql_data_dir }}" is empty ansible.builtin.file: path: "{{ postgresql_data_dir }}" @@ -466,7 +468,7 @@ - absent - directory when: (is_master | bool and patroni_cluster_bootstrap_method != "pgbackrest") - or (not is_master | bool and 'pgbackrest' not in patroni_create_replica_methods) # --delta restore + or (not is_master | bool and ('pgbackrest' not in patroni_create_replica_methods or new_node | default(false) | bool)) - name: Prepare PostgreSQL | make sure the custom WAL directory "{{ postgresql_wal_dir }}" is empty ansible.builtin.file: @@ -480,7 +482,7 @@ - directory when: (postgresql_wal_dir is defined and postgresql_wal_dir | length > 0) and ((is_master | bool and patroni_cluster_bootstrap_method != "pgbackrest") - or (not is_master | bool and 'pgbackrest' not in patroni_create_replica_methods)) # --delta restore + or (not is_master | bool and ('pgbackrest' not in patroni_create_replica_methods or new_node | default(false) | bool))) when: not postgresql_exists | bool or patroni_cluster_bootstrap_method != "initdb" tags: patroni, point_in_time_recovery From f6d8b4492e1fbad771445f2eec4ab34bae9762ff Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik Date: Mon, 11 Dec 2023 14:44:23 +0300 Subject: [PATCH 2/2] Fix trailing spaces --- roles/patroni/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/patroni/tasks/main.yml b/roles/patroni/tasks/main.yml index 6534588f6..f2a77d98d 100644 --- a/roles/patroni/tasks/main.yml +++ b/roles/patroni/tasks/main.yml @@ -456,7 +456,7 @@ not postgresql_conf_file.stat.exists # When performing PITR, we do not clear the directory if pgbackrest is used - # to be able to use the '--delta restore' option. + # to be able to use the '--delta restore' option. - name: Prepare PostgreSQL | make sure the data directory "{{ postgresql_data_dir }}" is empty ansible.builtin.file: path: "{{ postgresql_data_dir }}"