Skip to content

Commit

Permalink
pgBackRest: Ensure directories exist with correct permissions (#704)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks authored Jul 18, 2024
1 parent a7a116c commit 8c7d2b0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
4 changes: 2 additions & 2 deletions roles/pgbackrest/stanza-create/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
state: directory
owner: postgres
group: postgres
mode: "0755"
mode: "0750"
when: repo1_path | length > 0

- name: Create stanza "{{ pgbackrest_stanza }}"
Expand Down Expand Up @@ -47,7 +47,7 @@
state: directory
owner: "{{ pgbackrest_repo_user }}"
group: "{{ pgbackrest_repo_user }}"
mode: "0755"
mode: "0750"
when: repo1_path | length > 0

- name: Create stanza "{{ pgbackrest_stanza }}"
Expand Down
59 changes: 55 additions & 4 deletions roles/pgbackrest/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,31 @@
tags: pgbackrest, pgbackrest_install

- block:
- name: Ensure spool directory exist
- name: Ensure log directory exists
ansible.builtin.file:
path: "{{ item.value }}"
state: directory
owner: postgres
group: postgres
mode: "0755"
loop: "{{ pgbackrest_conf.global }}"
when: item.option == 'log-path'
loop_control:
label: "{{ item.value }}"

- name: Ensure repo directory exists
ansible.builtin.file:
path: "{{ item.value }}"
state: directory
owner: postgres
group: postgres
mode: "0750"
loop: "{{ pgbackrest_conf.global }}"
when: item.option == 'repo1-path' and pgbackrest_repo_host | length < 1
loop_control:
label: "{{ item.value }}"

- name: Ensure spool directory exists
ansible.builtin.file:
path: "{{ item.value }}"
state: directory
Expand All @@ -118,12 +142,13 @@
loop_control:
label: "{{ item.value }}"

- name: Ensure config directory exist
- name: Ensure config directory exists
ansible.builtin.file:
path: "{{ pgbackrest_conf_file | dirname }}"
state: directory
owner: postgres
group: postgres
mode: "0750"

- name: "Generate conf file {{ pgbackrest_conf_file }}"
ansible.builtin.template:
Expand All @@ -137,19 +162,45 @@

# Dedicated pgbackrest server (if "repo_host" is set)
- block:
- name: Ensure config directory exist
- name: Ensure log directory exists
ansible.builtin.file:
path: "{{ item.value }}"
state: directory
owner: "{{ pgbackrest_repo_user }}"
group: "{{ pgbackrest_repo_user }}"
mode: "0755"
loop: "{{ pgbackrest_server_conf.global }}"
when: item.option == 'log-path'
loop_control:
label: "{{ item.value }}"

- name: Ensure repo directory exists
ansible.builtin.file:
path: "{{ item.value }}"
state: directory
owner: "{{ pgbackrest_repo_user }}"
group: "{{ pgbackrest_repo_user }}"
mode: "0750"
loop: "{{ pgbackrest_server_conf.global }}"
when: item.option == 'repo1-path'
loop_control:
label: "{{ item.value }}"

- name: Ensure config directory exists
ansible.builtin.file:
path: "{{ pgbackrest_conf_file | dirname }}"
state: directory
owner: "{{ pgbackrest_repo_user }}"
group: "{{ pgbackrest_repo_user }}"
mode: "0750"

- name: Ensure stanza config directory exist
- name: Ensure stanza config directory exists
ansible.builtin.file:
path: "{{ pgbackrest_conf_file | dirname }}/conf.d"
state: directory
owner: "{{ pgbackrest_repo_user }}"
group: "{{ pgbackrest_repo_user }}"
mode: "0750"

- name: "Generate global conf file {{ pgbackrest_conf_file }}"
ansible.builtin.template:
Expand Down

0 comments on commit 8c7d2b0

Please sign in to comment.