Skip to content

Commit 6f01e90

Browse files
committed
chore: remove migrated ansible tasks for postgres setup
1 parent f7ff69b commit 6f01e90

File tree

1 file changed

+0
-295
lines changed

1 file changed

+0
-295
lines changed

ansible/tasks/setup-postgres.yml

Lines changed: 0 additions & 295 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,3 @@
1-
- name: Postgres - copy package
2-
copy:
3-
src: files/postgres/
4-
dest: /tmp/build/
5-
when: debpkg_mode
6-
7-
- name: Postgres - add PPA
8-
apt_repository:
9-
repo: "deb [ trusted=yes ] file:///tmp/build ./"
10-
state: present
11-
when: debpkg_mode
12-
13-
- name: Postgres - install commons
14-
apt:
15-
name: postgresql-common
16-
install_recommends: no
17-
when: debpkg_mode
18-
19-
- name: Do not create main cluster
20-
shell:
21-
cmd: sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf
22-
when: debpkg_mode
23-
24-
- name: Postgres - install server
25-
apt:
26-
name: postgresql-{{ postgresql_major }}={{ postgresql_release }}-1.pgdg24.04+1
27-
install_recommends: no
28-
when: debpkg_mode
29-
30-
- name: Postgres - remove PPA
31-
apt_repository:
32-
repo: "deb [ trusted=yes ] file:///tmp/build ./"
33-
state: absent
34-
when: debpkg_mode
35-
36-
- name: Postgres - cleanup package
37-
file:
38-
path: /tmp/build
39-
state: absent
40-
when: debpkg_mode
41-
42-
- name: install locales
43-
apt:
44-
name: locales
45-
state: present
46-
become: yes
47-
when: stage2_nix
48-
49-
- name: configure locales
50-
command: echo "C.UTF-8 UTF-8" > /etc/locale.gen && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
51-
become: yes
52-
when: stage2_nix
53-
54-
- name: locale-gen
55-
command: sudo locale-gen
56-
when: stage2_nix
57-
58-
- name: update-locale
59-
command: sudo update-locale
60-
when: stage2_nix
61-
62-
- name: Create symlink to /usr/lib/postgresql/bin
63-
shell:
64-
cmd: ln -s /usr/lib/postgresql/{{ postgresql_major }}/bin /usr/lib/postgresql/bin
65-
when: debpkg_mode
66-
67-
- name: create ssl-cert group
68-
group:
69-
name: ssl-cert
70-
state: present
71-
when: nixpkg_mode
72-
# the old method of installing from debian creates this group, but we must create it explicitly
73-
# for the nix built version
74-
75-
- name: create postgres group
76-
group:
77-
name: postgres
78-
state: present
79-
when: nixpkg_mode
80-
81-
- name: create postgres user
82-
shell: adduser --system --home /var/lib/postgresql --no-create-home --shell /bin/bash --group --gecos "PostgreSQL administrator" postgres
83-
args:
84-
executable: /bin/bash
85-
become: yes
86-
when: nixpkg_mode
87-
88-
- name: add postgres user to postgres group
89-
shell: usermod -a -G ssl-cert postgres
90-
args:
91-
executable: /bin/bash
92-
become: yes
93-
when: nixpkg_mode
94-
95-
- name: Create relevant directories
96-
file:
97-
path: '{{ item }}'
98-
recurse: yes
99-
state: directory
100-
owner: postgres
101-
group: postgres
102-
with_items:
103-
- '/home/postgres'
104-
- '/var/log/postgresql'
105-
- '/var/lib/postgresql'
106-
when: debpkg_mode or nixpkg_mode
107-
108-
- name: Allow adminapi to write custom config
109-
file:
110-
path: '{{ item }}'
111-
recurse: yes
112-
state: directory
113-
owner: postgres
114-
group: postgres
115-
mode: 0775
116-
with_items:
117-
- '/etc/postgresql'
118-
- '/etc/postgresql-custom'
119-
when: debpkg_mode or nixpkg_mode
120-
1211
- name: create placeholder config files
1222
file:
1233
path: '/etc/postgresql-custom/{{ item }}'
@@ -130,41 +10,6 @@
13010
- 'custom-overrides.conf'
13111
when: debpkg_mode or nixpkg_mode
13212

133-
# Move Postgres configuration files into /etc/postgresql
134-
# Add postgresql.conf
135-
- name: import postgresql.conf
136-
template:
137-
src: files/postgresql_config/postgresql.conf.j2
138-
dest: /etc/postgresql/postgresql.conf
139-
group: postgres
140-
when: debpkg_mode or nixpkg_mode
141-
142-
# Add pg_hba.conf
143-
- name: import pg_hba.conf
144-
template:
145-
src: files/postgresql_config/pg_hba.conf.j2
146-
dest: /etc/postgresql/pg_hba.conf
147-
group: postgres
148-
when: debpkg_mode or nixpkg_mode
149-
150-
# Add pg_ident.conf
151-
- name: import pg_ident.conf
152-
template:
153-
src: files/postgresql_config/pg_ident.conf.j2
154-
dest: /etc/postgresql/pg_ident.conf
155-
group: postgres
156-
when: debpkg_mode or nixpkg_mode
157-
158-
# Add custom config for read replicas set up
159-
- name: Move custom read-replica.conf file to /etc/postgresql-custom/read-replica.conf
160-
template:
161-
src: "files/postgresql_config/custom_read_replica.conf.j2"
162-
dest: /etc/postgresql-custom/read-replica.conf
163-
mode: 0664
164-
owner: postgres
165-
group: postgres
166-
when: debpkg_mode or nixpkg_mode
167-
16813
# Install extensions before init
16914
- name: Install Postgres extensions
17015
import_tasks: tasks/setup-docker.yml
@@ -175,148 +20,8 @@
17520
import_tasks: tasks/stage2-setup-postgres.yml
17621
when: stage2_nix
17722

178-
# init DB
179-
- name: Create directory on data volume
180-
file:
181-
path: '{{ item }}'
182-
recurse: yes
183-
state: directory
184-
owner: postgres
185-
group: postgres
186-
mode: 0750
187-
with_items:
188-
- "/data/pgdata"
189-
when: debpkg_mode or nixpkg_mode
190-
191-
- name: Link database data_dir to data volume directory
192-
file:
193-
src: "/data/pgdata"
194-
path: "/var/lib/postgresql/data"
195-
state: link
196-
force: yes
197-
when: debpkg_mode or nixpkg_mode
198-
199-
- name: Initialize the database
200-
become: yes
201-
become_user: postgres
202-
shell: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin"
203-
vars:
204-
ansible_command_timeout: 60
205-
when: debpkg_mode
206-
207-
- name: Make sure .bashrc exists
208-
file:
209-
path: /var/lib/postgresql/.bashrc
210-
state: touch
211-
owner: postgres
212-
group: postgres
213-
when: nixpkg_mode
214-
215-
- name: Check psql_version and modify supautils.conf and postgresql.conf if necessary
216-
block:
217-
- name: Check if psql_version is psql_orioledb
218-
set_fact:
219-
is_psql_oriole: "{{ psql_version in ['psql_orioledb-17'] }}"
220-
is_psql_17: "{{ psql_version in ['psql_17'] }}"
221-
222-
- name: Initialize the database stage2_nix (non-orioledb)
223-
become: yes
224-
become_user: postgres
225-
shell: source /var/lib/postgresql/.bashrc && /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin"
226-
args:
227-
executable: /bin/bash
228-
environment:
229-
LANG: en_US.UTF-8
230-
LANGUAGE: en_US.UTF-8
231-
LC_ALL: en_US.UTF-8
232-
LC_CTYPE: en_US.UTF-8
233-
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
234-
vars:
235-
ansible_command_timeout: 60
236-
when: stage2_nix and not is_psql_oriole and not is_psql_17
237-
238-
- name: Initialize the database stage2_nix (orioledb)
239-
become: yes
240-
become_user: postgres
241-
shell: >
242-
source /var/lib/postgresql/.bashrc && /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb
243-
-o "--allow-group-access"
244-
-o "--username=supabase_admin"
245-
-o "--locale-provider=icu"
246-
-o "--encoding=UTF-8"
247-
-o "--icu-locale=en_US.UTF-8"
248-
args:
249-
executable: /bin/bash
250-
environment:
251-
LANG: en_US.UTF-8
252-
LANGUAGE: en_US.UTF-8
253-
LC_ALL: en_US.UTF-8
254-
LC_CTYPE: en_US.UTF-8
255-
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
256-
vars:
257-
ansible_command_timeout: 60
258-
when: stage2_nix and (is_psql_oriole or is_psql_17)
259-
260-
- name: copy PG systemd unit
261-
template:
262-
src: files/postgresql_config/postgresql.service.j2
263-
dest: /etc/systemd/system/postgresql.service
264-
when: debpkg_mode or stage2_nix
265-
26623
- name: copy optimizations systemd unit
26724
template:
26825
src: files/database-optimizations.service.j2
26926
dest: /etc/systemd/system/database-optimizations.service
27027
when: debpkg_mode or stage2_nix
271-
272-
- name: initialize pg required state
273-
become: yes
274-
shell: |
275-
mkdir -p /run/postgresql
276-
chown -R postgres:postgres /run/postgresql
277-
when: stage2_nix and qemu_mode is defined
278-
279-
- name: Restart Postgres Database without Systemd
280-
become: yes
281-
become_user: postgres
282-
shell: |
283-
source /var/lib/postgresql/.bashrc
284-
/usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data start
285-
environment:
286-
LANG: en_US.UTF-8
287-
LANGUAGE: en_US.UTF-8
288-
LC_ALL: en_US.UTF-8
289-
LC_CTYPE: en_US.UTF-8
290-
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
291-
when: stage2_nix
292-
293-
294-
# Reload
295-
- name: System - systemd reload
296-
systemd:
297-
enabled: yes
298-
name: postgresql
299-
daemon_reload: yes
300-
when: debpkg_mode or stage2_nix
301-
302-
303-
- name: Add LOCALE_ARCHIVE to .bashrc
304-
lineinfile:
305-
dest: "/var/lib/postgresql/.bashrc"
306-
line: 'export LOCALE_ARCHIVE=/usr/lib/locale/locale-archive'
307-
create: yes
308-
become: yes
309-
when: nixpkg_mode
310-
311-
- name: Add LANG items to .bashrc
312-
lineinfile:
313-
dest: "/var/lib/postgresql/.bashrc"
314-
line: "{{ item }}"
315-
loop:
316-
- 'export LANG="en_US.UTF-8"'
317-
- 'export LANGUAGE="en_US.UTF-8"'
318-
- 'export LC_ALL="en_US.UTF-8"'
319-
- 'export LANG="en_US.UTF-8"'
320-
- 'export LC_CTYPE="en_US.UTF-8"'
321-
become: yes
322-
when: nixpkg_mode

0 commit comments

Comments
 (0)