-
-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathsetup-wal-g.yml
91 lines (81 loc) · 2.49 KB
/
setup-wal-g.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- name: Create wal-g group
group:
name: wal-g
state: present
when: nixpkg_mode
- name: Create wal-g user
user:
name: wal-g
shell: /bin/false
comment: WAL-G user
group: wal-g
groups: wal-g, postgres
when: nixpkg_mode
- name: Create a config directory owned by wal-g
file:
path: /etc/wal-g
state: directory
owner: wal-g
group: wal-g
mode: '0770'
when: nixpkg_mode
- name: Install wal-g 2 from nix binary cache
become: yes
shell: |
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"
when: stage2_nix
- name: Install wal-g 3 from nix binary cache
become: yes
shell: |
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"
when: stage2_nix
- name: Create symlink for wal-g-3 from Nix profile to /usr/local/bin
ansible.builtin.file:
src: /home/wal-g/.nix-profile/bin/wal-g-3
dest: /usr/local/bin/wal-g-v3
state: link
force: yes # This will replace existing file/symlink if it exists
become: yes # Need sudo to write to /usr/local/bin
when: stage2_nix
- name: Create symlink to make wal-g-v2 the default wal-g
ansible.builtin.file:
src: /home/wal-g/.nix-profile/bin/wal-g-2
dest: /usr/local/bin/wal-g
state: link
force: yes
become: yes
when: stage2_nix
- name: Create /etc/wal-g/config.json
file:
path: /etc/wal-g/config.json
state: touch
owner: wal-g
group: wal-g
mode: '0664'
- name: Move custom wal-g.conf file to /etc/postgresql-custom/wal-g.conf
template:
src: "files/postgresql_config/custom_walg.conf.j2"
dest: /etc/postgresql-custom/wal-g.conf
mode: 0664
owner: postgres
group: postgres
- name: Add script to be run for restore_command
template:
src: "files/walg_helper_scripts/wal_fetch.sh"
dest: /home/postgres/wal_fetch.sh
mode: 0500
owner: postgres
group: postgres
- name: Add helper script for wal_fetch.sh
template:
src: "files/walg_helper_scripts/wal_change_ownership.sh"
dest: /root/wal_change_ownership.sh
mode: 0700
owner: root
- name: Include /etc/postgresql-custom/wal-g.conf in postgresql.conf
become: yes
replace:
path: /etc/postgresql/postgresql.conf
regexp: "#include = '/etc/postgresql-custom/wal-g.conf'"
replace: "include = '/etc/postgresql-custom/wal-g.conf'"
when: stage2_nix