Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgBackRest: Run "Create stanza" only on master if it's not posix #786

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions automation/roles/pgbackrest/stanza-create/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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

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

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