Skip to content

Commit 6577048

Browse files
authored
Run "Create stanza" only on master if it's not posix (#786)
This update modifies the stanza creation process for pgbackrest to run on all nodes only if repo1-type is posix. For other types (e.g., S3), the stanza creation is limited to the primary node, addressing errors caused by running stanza creation on multiple hosts in non-posix setups.
1 parent c9c9f02 commit 6577048

File tree

1 file changed

+5
-3
lines changed
  • automation/roles/pgbackrest/stanza-create/tasks

1 file changed

+5
-3
lines changed

automation/roles/pgbackrest/stanza-create/tasks/main.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# Create a stanza locally (if "pgbackrest_repo_host" is not set)
44
- block:
5-
- name: Get repo1-path value
5+
- name: Get repo1-path and repo1_type value
66
ansible.builtin.set_fact:
77
repo1_path: "{{ pgbackrest_conf['global'] | selectattr('option', 'equalto', 'repo1-path') | map(attribute='value') | list | first }}"
8-
when: pgbackrest_repo_type | lower == 'posix'
8+
repo1_type: "{{ pgbackrest_conf['global'] | selectattr('option', 'equalto', 'repo1-type') | map(attribute='value') | list | first }}"
99

1010
- name: "Make sure the {{ repo1_path }} directory exists"
1111
ansible.builtin.file:
@@ -14,7 +14,7 @@
1414
owner: postgres
1515
group: postgres
1616
mode: "0750"
17-
when: repo1_path | default('') | length > 0
17+
when: repo1_type | lower == 'posix'
1818

1919
- name: Create stanza "{{ pgbackrest_stanza }}"
2020
become: true
@@ -24,6 +24,8 @@
2424
changed_when:
2525
- stanza_create_result.rc == 0
2626
- stanza_create_result.stdout is not search("already exists")
27+
when: repo1_type | lower == 'posix' or
28+
(repo1_type | lower != 'posix' and inventory_hostname == groups['master'][0]) # run only on master if it's not posix
2729
when:
2830
- pgbackrest_repo_host | length < 1
2931
- "'postgres_cluster' in group_names"

0 commit comments

Comments
 (0)