Skip to content

Commit bec3bfc

Browse files
committed
fix: Fix PostgreSQL initdb and config symlinks
- Explicitly set the data directory using `--pgdata` in `pg_ctl initdb` commands.
1 parent e094056 commit bec3bfc

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

ansible/tasks/setup-postgres.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
become: true
266266
become_user: 'postgres'
267267
ansible.builtin.command:
268-
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin"
268+
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin" -o "--pgdata /var/lib/postgresql/data"
269269
vars:
270270
ansible_command_timeout: 60
271271
when:
@@ -293,7 +293,7 @@
293293
become: true
294294
become_user: 'postgres'
295295
ansible.builtin.command:
296-
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin"
296+
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin" -o "--pgdata /var/lib/postgresql/data"
297297
environment:
298298
LANG: en_US.UTF-8
299299
LANGUAGE: en_US.UTF-8
@@ -310,7 +310,7 @@
310310
become: true
311311
become_user: 'postgres'
312312
ansible.builtin.command:
313-
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin" -o "--locale-provider=icu" -o "--encoding=UTF-8" -o "--icu-locale=en_US.UTF-8"
313+
cmd: /usr/lib/postgresql/bin/pg_ctl -D /var/lib/postgresql/data initdb -o "--allow-group-access" -o "--username=supabase_admin" -o "--locale-provider=icu" -o "--encoding=UTF-8" -o "--icu-locale=en_US.UTF-8" -o "--pgdata /var/lib/postgresql/data"
314314
environment:
315315
LANG: en_US.UTF-8
316316
LANGUAGE: en_US.UTF-8
@@ -322,19 +322,6 @@
322322
when:
323323
- (is_psql_oriole or is_psql_17)
324324

325-
- name: Symlink the conf files in PGDATA to the actually-in-use conf files
326-
ansible.builtin.file:
327-
force: true
328-
path: /var/lib/postgresql/data/{{ conf_item }}
329-
src: /etc/postgresql/{{ conf_item }}
330-
state: link
331-
loop:
332-
- pg_hba.conf
333-
- pg_ident.conf
334-
- postgresql.conf
335-
loop_control:
336-
loop_var: conf_item
337-
338325
- name: copy PG and optimizations systemd units
339326
ansible.builtin.template:
340327
dest: "/etc/systemd/system/{{ systemd_svc_item | basename }}"
@@ -358,6 +345,19 @@
358345
- stage2_nix
359346
- qemu_mode is defined
360347

348+
- name: Symlink the conf files in PGDATA to the actually-in-use conf files
349+
ansible.builtin.file:
350+
force: true
351+
path: /var/lib/postgresql/data/{{ conf_item }}
352+
src: /etc/postgresql/{{ conf_item }}
353+
state: link
354+
loop:
355+
- pg_hba.conf
356+
- pg_ident.conf
357+
- postgresql.conf
358+
loop_control:
359+
loop_var: conf_item
360+
361361
- name: Restart Postgres Database without Systemd
362362
become: true
363363
become_user: 'postgres'

0 commit comments

Comments
 (0)