|
| 1 | +- name: Create pgBackRest group |
| 2 | + group: |
| 3 | + name: pgbackrest |
| 4 | + state: present |
| 5 | + when: nixpkg_mode |
| 6 | + |
| 7 | +- name: Create pgBackRest user |
| 8 | + user: |
| 9 | + name: pgbackrest |
| 10 | + comment: pgBackRest user |
| 11 | + group: pgbackrest |
| 12 | + groups: pgbackrest, postgres |
| 13 | + shell: /sbin/nologin |
| 14 | + system: true |
| 15 | + home: /var/lib/pgbackrest |
| 16 | + when: nixpkg_mode |
| 17 | + |
| 18 | +- name: Install pgBackRest |
| 19 | + become: true |
| 20 | + become_user: pgbackrest |
| 21 | + shell: | |
| 22 | + sudo -u pgbackrest bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#pg-backrest" |
| 23 | + when: stage2_nix |
| 24 | + |
| 25 | +- name: Create needed directories for pgBackRest |
| 26 | + file: |
| 27 | + path: "{{ backrest_dir }}" |
| 28 | + state: directory |
| 29 | + owner: pgbackrest |
| 30 | + group: postgres |
| 31 | + mode: '0770' |
| 32 | + loop: |
| 33 | + - /etc/pgbackrest/conf.d |
| 34 | + - /var/lib/pgbackrest |
| 35 | + - /var/spool/pgbackrest |
| 36 | + - /var/log/pgbackrest |
| 37 | + loop_control: |
| 38 | + loop_var: backrest_dir |
| 39 | + when: nixpkg_mode |
| 40 | + |
| 41 | +- name: Symlink pgbackrest.conf |
| 42 | + file: |
| 43 | + path: /etc/pgbackrest/pgbackrest.conf |
| 44 | + src: /etc/pgbackrest.conf |
| 45 | + state: link |
| 46 | + force: true |
| 47 | + |
| 48 | +- name: Move pgBackRest files to /etc/pgbackrest |
| 49 | + copy: |
| 50 | + dest: "/etc/pgbackrest/{{ conf_item['path'] }}/{{ conf_item['name'] }}" |
| 51 | + group: postgres |
| 52 | + mode: '0644' |
| 53 | + owner: pgbackrest |
| 54 | + src: "files/pgbackrest_config/{{ conf_item['name'] }}" |
| 55 | + loop: |
| 56 | + - {name: computed_globals.conf, path: conf.d} |
| 57 | + - {name: pgbackrest.conf, path: ''} |
| 58 | + - {name: repo1_async.conf, path: conf.d} |
| 59 | + - {name: repo1_encrypted.conf, path: conf.d} |
| 60 | + - {name: repo1.conf, path: conf.d} |
| 61 | + loop_control: |
| 62 | + loop_var: conf_item |
| 63 | + when: stage2_nix |
| 64 | + |
| 65 | +- name: Symlink pgBackRest binary |
| 66 | + file: |
| 67 | + path: /usr/bin/pgbackrest |
| 68 | + src: /var/lib/pgbackrest/.nix-profile/bin/pgbackrest |
| 69 | + state: link |
| 70 | + |
| 71 | +- name: Sticky bit the pgBackRest binary |
| 72 | + file: |
| 73 | + path: /var/lib/pgbackrest/.nix-profile/bin/pgbackrest |
| 74 | + mode: '4755' |
| 75 | + become: true |
0 commit comments