Skip to content

Commit 7345b6a

Browse files
committed
refactor(setup-pgbackrest.yml): refactor as per Sam
2 parents 6b71d69 + 56e3d22 commit 7345b6a

File tree

2 files changed

+190
-204
lines changed

2 files changed

+190
-204
lines changed

ansible/tasks/setup-pgbackrest.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,20 @@
6363
loop_var: conf_item
6464
when: stage2_nix
6565

66-
- name: Symlink pgBackRest binary
67-
ansible.legacy.file:
68-
path: /usr/bin/pgbackrest
69-
src: /var/lib/pgbackrest/.nix-profile/bin/pgbackrest
70-
state: link
66+
- name: Configure sudoers for pgBackRest
67+
ansible.builtin.lineinfile:
68+
create: yes
69+
line: 'postgres ALL=(pgbackrest) NOPASSWD: /var/lib/pgbackrest/.nix-profile/bin/pgbackrest'
70+
mode: '0440'
71+
path: '/etc/sudoers.d/pgbackrest'
72+
validate: 'visudo -cf %s'
7173

72-
- name: Sticky bit the pgBackRest binary
73-
ansible.legacy.file:
74-
mode: '4755'
75-
path: /var/lib/pgbackrest/.nix-profile/bin/pgbackrest
76-
become: true
74+
- name: Create pgBackRest wrapper script
75+
ansible.builtin.copy:
76+
content: |
77+
#!/bin/bash
78+
exec sudo -u pgbackrest /var/lib/pgbackrest/.nix-profile/bin/pgbackrest "$@"
79+
dest: '/usr/bin/pgbackrest'
80+
group: 'root'
81+
mode: '0755'
82+
owner: 'root'

0 commit comments

Comments
 (0)