forked from supabase/postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaybook.yml
More file actions
229 lines (191 loc) · 6.44 KB
/
Copy pathplaybook.yml
File metadata and controls
229 lines (191 loc) · 6.44 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
- hosts: all
become: yes
pre_tasks:
- import_tasks: tasks/setup-system.yml
vars_files:
- ./vars.yml
vars:
sql_files:
- {
source: "pgbouncer_config/pgbouncer_auth_schema.sql",
dest: "00-schema.sql",
}
- { source: "stat_extension.sql", dest: "01-extension.sql" }
environment:
PATH: /usr/lib/postgresql/bin:{{ ansible_env.PATH }}
tasks:
- set_fact:
supabase_internal: true
tags:
- install-supabase-internal
- set_fact:
parallel_jobs: 16
- name: Install Postgres from source
import_tasks: tasks/setup-postgres.yml
- name: Install PgBouncer
import_tasks: tasks/setup-pgbouncer.yml
tags:
- install-pgbouncer
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Install WAL-G
import_tasks: tasks/setup-wal-g.yml
when: debpkg_mode or nixpkg_mode or stage2_nix
- name: Install Gotrue
import_tasks: tasks/setup-gotrue.yml
tags:
- install-gotrue
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Install PostgREST
import_tasks: tasks/setup-postgrest.yml
tags:
- install-postgrest
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Install Envoy
import_tasks: tasks/setup-envoy.yml
tags:
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Install Kong
import_tasks: tasks/setup-kong.yml
tags:
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Install nginx
import_tasks: tasks/setup-nginx.yml
tags:
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Install Supabase specific content
import_tasks: tasks/setup-supabase-internal.yml
tags:
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Fix IPv6 NDisc issues
import_tasks: tasks/fix_ipv6_ndisc.yml
tags:
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Start Postgres Database without Systemd
become: yes
become_user: postgres
shell:
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data start
when: debpkg_mode
- name: Adjust APT update intervals
copy:
src: files/apt_periodic
dest: /etc/apt/apt.conf.d/10periodic
when: debpkg_mode or nixpkg_mode
- name: Transfer init SQL files
copy:
src: files/{{ item.source }}
dest: /tmp/{{ item.dest }}
loop: "{{ sql_files }}"
when: debpkg_mode or stage2_nix
- name: Create postgres role
become: yes
become_user: postgres
shell:
cmd: /usr/lib/postgresql/bin/psql --username=supabase_admin -d postgres -c "create role postgres superuser login; alter database postgres owner to postgres;"
when: debpkg_mode or stage2_nix
- name: Execute init SQL files
become: yes
become_user: postgres
shell:
cmd: /usr/lib/postgresql/bin/psql -f /tmp/{{ item.dest }}
loop: "{{ sql_files }}"
when: debpkg_mode or stage2_nix
- name: Delete SQL scripts
file:
path: /tmp/{{ item.dest }}
state: absent
loop: "{{ sql_files }}"
when: debpkg_mode or stage2_nix
- name: First boot optimizations
import_tasks: tasks/internal/optimizations.yml
tags:
- install-supabase-internal
when: debpkg_mode or stage2_nix
- name: Finalize AMI
import_tasks: tasks/finalize-ami.yml
tags:
- install-supabase-internal
when: debpkg_mode or nixpkg_mode
- name: Enhance fail2ban
import_tasks: tasks/setup-fail2ban.yml
when: debpkg_mode or nixpkg_mode
# Install EC2 instance connect
# Only for AWS images
- name: install EC2 instance connect
become: yes
apt:
pkg:
- ec2-instance-connect
tags:
- aws-only
when: qemu_mode is undefined
# Install this at the end to prevent it from kicking in during the apt process, causing conflicts
- name: Install security tools
become: yes
apt:
pkg:
- unattended-upgrades
update_cache: yes
cache_valid_time: 3600
- name: Clean out build dependencies
import_tasks: tasks/clean-build-dependencies.yml
- name: Restart Postgres Database without Systemd
become: yes
become_user: postgres
shell:
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data restart -o "-c shared_preload_libraries='pg_tle'"
when: debpkg_mode
- name: Run migrations
import_tasks: tasks/setup-migrations.yml
tags:
- migrations
when: debpkg_mode or stage2_nix
- name: Stop Postgres Database without Systemd
become: yes
become_user: postgres
shell:
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data stop
when: debpkg_mode
- name: Run unit tests
import_tasks: tasks/test-image.yml
tags:
- unit-tests
when: debpkg_mode or stage2_nix
- name: Collect Postgres binaries
import_tasks: tasks/internal/collect-pg-binaries.yml
tags:
- collect-binaries
when: debpkg_mode
- name: Install osquery from nixpkgs binary cache
become: yes
shell: |
apt autoremove -y --purge snapd
when: stage2_nix
- name: Install osquery from nixpkgs binary cache
become: yes
shell: |
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile install github:nixos/nixpkgs/f98ec4f73c762223d62bee706726138cb6ea27cc#osquery"
when: stage2_nix
- name: Run osquery permission checks
become: yes
shell: |
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && /usr/bin/python3 /tmp/ansible-playbook/ansible/files/permission_check.py {{ '--qemu' if qemu_mode is defined else '' }}"
when: stage2_nix
- name: Remove osquery
become: yes
shell: |
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile remove osquery"
when: stage2_nix
- name: nix collect garbage
become: yes
shell: |
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix-collect-garbage -d"
when: stage2_nix