diff --git a/automation/roles/pgbackrest/stanza-create/tasks/main.yml b/automation/roles/pgbackrest/stanza-create/tasks/main.yml index c1947e0d0..335e5e55e 100644 --- a/automation/roles/pgbackrest/stanza-create/tasks/main.yml +++ b/automation/roles/pgbackrest/stanza-create/tasks/main.yml @@ -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: @@ -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 @@ -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"