|
1 | | -- name: Create wal-g group |
2 | | - group: |
3 | | - name: wal-g |
4 | | - state: present |
5 | | - when: nixpkg_mode |
| 1 | +- name: Execute wal-g things when nixpkg_mode |
| 2 | + when: |
| 3 | + - nixpkg_mode |
| 4 | + block: |
| 5 | + - name: Create wal-g group |
| 6 | + ansible.builtin.group: |
| 7 | + name: 'wal-g' |
| 8 | + state: 'present' |
6 | 9 |
|
7 | | -- name: Create wal-g user |
8 | | - user: |
9 | | - name: wal-g |
10 | | - shell: /bin/false |
11 | | - comment: WAL-G user |
12 | | - group: wal-g |
13 | | - groups: wal-g, postgres |
14 | | - when: nixpkg_mode |
15 | | -- name: Create a config directory owned by wal-g |
16 | | - file: |
17 | | - path: /etc/wal-g |
18 | | - state: directory |
19 | | - owner: wal-g |
20 | | - group: wal-g |
21 | | - mode: '0770' |
22 | | - when: nixpkg_mode |
| 10 | + - name: Create wal-g user |
| 11 | + ansible.builtin.user: |
| 12 | + comment: 'WAL-G user' |
| 13 | + group: 'wal-g' |
| 14 | + groups: 'wal-g, postgres' |
| 15 | + name: 'wal-g' |
| 16 | + shell: '/usr/bin/nologin' |
| 17 | + system: true |
23 | 18 |
|
24 | | -- name: Install wal-g 2 from nix binary cache |
25 | | - become: yes |
26 | | - shell: | |
27 | | - sudo -u wal-g bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#wal-g-2" |
28 | | - when: stage2_nix |
| 19 | + - name: Create a config directory owned by wal-g |
| 20 | + ansible.builtin.file: |
| 21 | + group: 'wal-g' |
| 22 | + mode: '0770' |
| 23 | + owner: 'wal-g' |
| 24 | + path: '/etc/wal-g' |
| 25 | + state: 'directory' |
29 | 26 |
|
30 | | -- name: Install wal-g 3 from nix binary cache |
31 | | - become: yes |
32 | | - shell: | |
33 | | - sudo -u wal-g bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#wal-g-3" |
34 | | - when: stage2_nix |
| 27 | +- name: Execute wal-g things when stage2_nix |
| 28 | + when: |
| 29 | + - stage2_nix |
| 30 | + block: |
| 31 | + - name: Install wal-g 2 from nix binary cache |
| 32 | + ansible.builtin.shell: |
| 33 | + cmd: sudo -u wal-g bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#wal-g-2" |
| 34 | + become: true |
35 | 35 |
|
36 | | -- name: Create symlink for wal-g-3 from Nix profile to /usr/local/bin |
37 | | - ansible.builtin.file: |
38 | | - src: /home/wal-g/.nix-profile/bin/wal-g-3 |
39 | | - dest: /usr/local/bin/wal-g-v3 |
40 | | - state: link |
41 | | - force: yes # This will replace existing file/symlink if it exists |
42 | | - become: yes # Need sudo to write to /usr/local/bin |
43 | | - when: stage2_nix |
| 36 | + - name: Install wal-g 3 from nix binary cache |
| 37 | + ansible.builtin.shell: |
| 38 | + cmd: sudo -u wal-g bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:supabase/postgres/{{ git_commit_sha }}#wal-g-3" |
| 39 | + become: true |
44 | 40 |
|
45 | | -- name: Create symlink to make wal-g-v2 the default wal-g |
46 | | - ansible.builtin.file: |
47 | | - src: /home/wal-g/.nix-profile/bin/wal-g-2 |
48 | | - dest: /usr/local/bin/wal-g |
49 | | - state: link |
50 | | - force: yes |
51 | | - become: yes |
52 | | - when: stage2_nix |
| 41 | + - name: Create symlink for wal-g-3 from Nix profile to /usr/local/bin |
| 42 | + ansible.builtin.file: |
| 43 | + dest: '/usr/local/bin/wal-g-v3' |
| 44 | + force: true |
| 45 | + src: '/home/wal-g/.nix-profile/bin/wal-g-3' |
| 46 | + state: 'link' |
| 47 | + become: true |
53 | 48 |
|
54 | | -- name: Create /etc/wal-g/config.json |
55 | | - file: |
56 | | - path: /etc/wal-g/config.json |
57 | | - state: touch |
58 | | - owner: wal-g |
59 | | - group: wal-g |
60 | | - mode: '0664' |
61 | | - when: stage2_nix |
| 49 | + - name: Create symlink to make wal-g-v2 the default wal-g |
| 50 | + ansible.builtin.file: |
| 51 | + dest: '/usr/local/bin/wal-g' |
| 52 | + force: true |
| 53 | + src: '/home/wal-g/.nix-profile/bin/wal-g-2' |
| 54 | + state: 'link' |
| 55 | + become: true |
62 | 56 |
|
63 | | -- name: Move custom wal-g.conf file to /etc/postgresql-custom/conf.d/wal-g.conf |
64 | | - copy: |
65 | | - src: "files/postgresql_config/conf.d/wal-g.conf" |
66 | | - dest: /etc/postgresql-custom/conf.d/wal-g.conf |
67 | | - mode: 0664 |
68 | | - owner: postgres |
69 | | - group: postgres |
70 | | - when: stage2_nix |
| 57 | + - name: Create /etc/wal-g/config.json |
| 58 | + ansible.builtin.file: |
| 59 | + group: 'wal-g' |
| 60 | + mode: '0664' |
| 61 | + owner: 'wal-g' |
| 62 | + path: '/etc/wal-g/config.json' |
| 63 | + state: 'touch' |
71 | 64 |
|
72 | | -- name: Add script to be run for restore_command |
73 | | - template: |
74 | | - src: "files/walg_helper_scripts/wal_fetch.sh" |
75 | | - dest: /home/postgres/wal_fetch.sh |
76 | | - mode: 0500 |
77 | | - owner: postgres |
78 | | - group: postgres |
79 | | - when: stage2_nix |
| 65 | + - name: Move custom wal-g.conf file to /etc/postgresql-custom/wal-g.conf |
| 66 | + ansible.builtin.template: |
| 67 | + dest: '/etc/postgresql-custom/wal-g.conf' |
| 68 | + group: 'postgres' |
| 69 | + mode: '0664' |
| 70 | + owner: 'postgres' |
| 71 | + src: 'files/postgresql_config/custom_walg.conf.j2' |
80 | 72 |
|
81 | | -- name: Add helper script for wal_fetch.sh |
82 | | - template: |
83 | | - src: "files/walg_helper_scripts/wal_change_ownership.sh" |
84 | | - dest: /root/wal_change_ownership.sh |
85 | | - mode: 0700 |
86 | | - owner: root |
87 | | - when: stage2_nix |
| 73 | + - name: Add script to be run for restore_command |
| 74 | + ansible.builtin.template: |
| 75 | + dest: '/home/postgres/wal_fetch.sh' |
| 76 | + group: 'postgres' |
| 77 | + mode: '0500' |
| 78 | + owner: 'postgres' |
| 79 | + src: 'files/walg_helper_scripts/wal_fetch.sh' |
| 80 | + |
| 81 | + - name: Add helper script for wal_fetch.sh |
| 82 | + ansible.builtin.template: |
| 83 | + dest: '/root/wal_change_ownership.sh' |
| 84 | + mode: '0700' |
| 85 | + owner: 'root' |
| 86 | + src: 'files/walg_helper_scripts/wal_change_ownership.sh' |
| 87 | + |
| 88 | + - name: Move custom wal-g.conf file to /etc/postgresql-custom/conf.d/wal-g.conf |
| 89 | + ansible.builtin.copy: |
| 90 | + dest: '/etc/postgresql-custom/conf.d/wal-g.conf' |
| 91 | + group: 'postgresq' |
| 92 | + mode: '0664' |
| 93 | + owner: 'postgres' |
| 94 | + src: 'files/postgresql_config/conf.d/wal-g.conf' |
0 commit comments