Skip to content

Commit 6a87d00

Browse files
authored
Merge pull request #16 from supabase/develop
supabase/postgres v0.12.0
2 parents e3de28b + 86878e8 commit 6a87d00

16 files changed

+90
-169
lines changed

amazon.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
"aws_access_key": "",
44
"aws_secret_key": "",
55
"region": "",
6+
"ami": "",
67
"name": ""
78
},
89
"builders": [{
910
"type": "amazon-ebs",
1011
"access_key": "{{user `aws_access_key`}}",
1112
"secret_key": "{{user `aws_secret_key`}}",
1213
"region": "{{user `region`}}",
13-
"source_ami": "ami-0f7719e8b7ba25c61",
14-
"instance_type": "t2.micro",
14+
"source_ami": "{{user `ami`}}",
15+
"instance_type": "t2.large",
1516
"ssh_username": "ubuntu",
1617
"ami_name": "{{user `name`}}",
1718
"launch_block_device_mappings": [{
1819
"device_name": "/dev/sda1",
19-
"encrypted": true,
20-
"kms_key_id": "44e7e739-21f1-4678-829e-d1ac63d121b4",
2120
"iops": 400,
2221
"volume_type": "io1",
2322
"volume_size": 8,
@@ -35,6 +34,7 @@
3534
"type": "shell",
3635
"scripts": [
3736
"scripts/01-test",
37+
"scripts/02-credentials_cleanup.sh",
3838
"scripts/90-cleanup.sh",
3939
"scripts/91-log_cleanup.sh",
4040
"scripts/99-img_check.sh"

ansible/files/ACCC4CF8.asc

-77
This file was deleted.

ansible/files/apt_periodic

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
APT::Periodic::Update-Package-Lists "1";
2+
APT::Periodic::Download-Upgradeable-Packages "1";
3+
APT::Periodic::AutocleanInterval "7";
4+
APT::Periodic::Unattended-Upgrade "1";

ansible/files/kong.conf.j2

-7
This file was deleted.

ansible/files/kong.service.j2

-20
This file was deleted.

ansible/files/postgresql.service.j2

-5
This file was deleted.

ansible/files/postgrest.service.j2

-17
This file was deleted.

ansible/files/supabase.service.j2

-24
This file was deleted.

ansible/playbook.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@
2929
file:
3030
path: /tmp/00-schema.sql
3131
state: absent
32-
33-
- name: Set up password for superadmin postgres
34-
become: yes
35-
become_user: postgres
36-
postgresql_user:
37-
name: postgres
38-
password: "{{ postgres_superadmin_password }}"
3932

33+
- name: Adjust APT update intervals
34+
copy:
35+
src: files/apt_periodic
36+
dest: /etc/apt/apt.conf.d/10periodic
37+
4038
- name: UFW - Allow SSH connections
4139
ufw:
4240
rule: allow

ansible/tasks/setup-extensions.yml

+31-1
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,44 @@
4343
update_cache: yes
4444
cache_valid_time: 3600
4545

46+
- name: pgAudit - download & install dependencies
47+
apt:
48+
pkg:
49+
- postgresql-server-dev-12
50+
- libssl-dev
51+
- libkrb5-dev
52+
update_cache: yes
53+
install_recommends: no
54+
55+
- name: pgAudit - download latest release
56+
git:
57+
repo: https://github.com/pgaudit/pgaudit.git
58+
dest: /tmp/pgaudit
59+
become: yes
60+
61+
- name: pgAudit - build
62+
make:
63+
chdir: /tmp/pgaudit
64+
target: check
65+
params:
66+
USE_PGXS: 1
67+
become: yes
68+
69+
- name: pgAudit - install
70+
make:
71+
chdir: /tmp/pgaudit
72+
target: install
73+
params:
74+
USE_PGXS: 1
75+
become: yes
76+
4677
- name: plv8 - download & install dependencies
4778
apt:
4879
pkg:
4980
- build-essential
5081
- ca-certificates
5182
- curl
5283
- git-core
53-
- python
5484
- gpp
5585
- cpp
5686
- pkg-config

ansible/tasks/setup-system.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,30 @@
44
apt: update_cache=yes upgrade=yes
55
# SEE http://archive.vn/DKJjs#parameter-upgrade
66

7+
- name: add universe repository for bionic
8+
apt_repository:
9+
repo: deb http://archive.ubuntu.com/ubuntu bionic universe
10+
state: present
11+
712
- name: Install essentials
813
apt:
914
pkg:
1015
- ufw
16+
- fail2ban
17+
- unattended-upgrades
18+
- python3
19+
- python3-pip
1120
update_cache: yes
1221
cache_valid_time: 3600
1322

23+
- name: Adjust APT update intervals
24+
copy:
25+
src: files/apt_periodic
26+
dest: /etc/apt/apt.conf.d/10periodic
27+
1428
- name: Install psycopg2 to enable ansible postgreSQL features
15-
pip: name=psycopg2-binary
29+
pip:
30+
name: psycopg2-binary
1631

1732
- name: System - Create services.slice
1833
template:

ansible/vars.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ postgresql_ext_install_dev_headers: yes
1111
# Warning: Make sure the postgresql & postgis versions are compatible with one another
1212
postgresql_ext_postgis_version: 3
1313

14-
postgresql_shared_preload_libraries: [pg_stat_statements]
14+
postgresql_shared_preload_libraries: [pg_stat_statements, pgaudit]
1515

1616
postgresql_pg_hba_custom:
1717
- {type: "host", database: "all", user: "all", address: "0.0.0.0/0", method: "md5" }
1818

19-
postgres_superadmin_password: "a1b2c3d4e5f6g7"
20-
2119
pgtap_release: v1.1.0
22-
pgtap_release_checksum: sha1:cca57708e723de18735a723b774577dc52f6f31e
20+
pgtap_release_checksum: sha1:cca57708e723de18735a723b774577dc52f6f31e
21+
22+
postgresql_log_destination: "csvlog"
23+
postgresql_logging_collector: on
24+
postgresql_log_filename: "postgresql.log"
25+
postgresql_log_rotation_age: 0
26+
postgresql_log_rotation_size: 0

digitalOcean.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"region": "{{user `region`}}",
1111
"size": "s-1vcpu-1gb",
1212
"ssh_username": "root",
13-
"snapshot_name": "supabase-postgresql-0.0.11"
13+
"snapshot_name": "supabase-postgresql-0.12.0"
1414
}],
1515
"provisioners": [
1616
{

docker/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ RUN git clone git://github.com/theory/pgtap.git \
2323
RUN apt-get update \
2424
&& apt-get install postgresql-plpython3-12 -y
2525

26+
# install pgAudit
27+
RUN pgAuditDependencies="postgresql-server-dev-$PG_MAJOR \
28+
libssl-dev \
29+
libkrb5-dev \
30+
git-core" \
31+
&& apt-get update \
32+
&& apt-get install -y --no-install-recommends ${pgAuditDependencies} \
33+
&& cd /tmp \
34+
&& git clone https://github.com/pgaudit/pgaudit.git \
35+
&& cd pgaudit \
36+
&& git checkout master \
37+
&& make check USE_PGXS=1 \
38+
&& make install USE_PGXS=1
39+
2640
# install plv8
2741
ENV PLV8_VERSION=r3.0alpha
2842

docker/mnt/init-permissions.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
set -e
33

44
echo "host replication $POSTGRES_USER 0.0.0.0/0 trust" >> $PGDATA/pg_hba.conf
5-
echo "shared_preload_libraries = 'pg_stat_statements'" >> $PGDATA/postgresql.conf
5+
echo "shared_preload_libraries = 'pg_stat_statements, pgaudit'" >> $PGDATA/postgresql.conf
66
echo "pg_stat_statements.max = 10000" >> $PGDATA/postgresql.conf
77
echo "pg_stat_statements.track = all" >> $PGDATA/postgresql.conf
88
echo "wal_level=logical" >> $PGDATA/postgresql.conf
99
echo "max_replication_slots=5" >> $PGDATA/postgresql.conf
1010
echo "max_wal_senders=10" >> $PGDATA/postgresql.conf
11+
echo "log_destination='csvlog'" >> $PGDATA/postgresql.conf
12+
echo "logging_collector=on" >> $PGDATA/postgresql.conf
13+
echo "log_filename='postgresql.log'" >> $PGDATA/postgresql.conf
14+
echo "log_rotation_age=0" >> $PGDATA/postgresql.conf
15+
echo "log_rotation_size=0" >> $PGDATA/postgresql.conf

scripts/02-credentials_cleanup.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sudo rm /home/ubuntu/.ssh/authorized_keys

0 commit comments

Comments
 (0)