Skip to content

Commit 2fb7958

Browse files
committed
feat: use icu for locales only if building orioledb
1 parent 1444882 commit 2fb7958

File tree

2 files changed

+52
-17
lines changed

2 files changed

+52
-17
lines changed

ansible/tasks/setup-postgres.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,43 @@
204204
ansible_command_timeout: 60
205205
when: debpkg_mode
206206

207-
- name: Initialize the database stage2_nix
208-
become: yes
209-
become_user: postgres
210-
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"
211-
args:
212-
executable: /bin/bash
213-
environment:
214-
LANG: en_US.UTF-8
215-
LANGUAGE: en_US.UTF-8
216-
LC_ALL: en_US.UTF-8
217-
LC_CTYPE: en_US.UTF-8
218-
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
219-
vars:
220-
ansible_command_timeout: 60
221-
# Circumvents the following error:
222-
# "Timeout (12s) waiting for privilege escalation prompt"
223-
when: stage2_nix
207+
- name: Check psql_version and modify supautils.conf and postgresql.conf if necessary
208+
block:
209+
- name: Check if psql_version is psql_orioledb
210+
set_fact:
211+
is_psql_oriole: "{{ psql_version in ['psql_orioledb-16', 'psql_orioledb-17'] }}"
212+
213+
- name: Initialize the database stage2_nix (non-orioledb)
214+
become: yes
215+
become_user: postgres
216+
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"
217+
args:
218+
executable: /bin/bash
219+
environment:
220+
LANG: en_US.UTF-8
221+
LANGUAGE: en_US.UTF-8
222+
LC_ALL: en_US.UTF-8
223+
LC_CTYPE: en_US.UTF-8
224+
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
225+
vars:
226+
ansible_command_timeout: 60
227+
when: stage2_nix and not is_psql_oriole
228+
229+
- name: Initialize the database stage2_nix (orioledb)
230+
become: yes
231+
become_user: postgres
232+
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" -o "--locale-provider=icu" -o "--encoding=UTF-8" -o "--icu-locale=en_US.UTF-8"
233+
args:
234+
executable: /bin/bash
235+
environment:
236+
LANG: en_US.UTF-8
237+
LANGUAGE: en_US.UTF-8
238+
LC_ALL: en_US.UTF-8
239+
LC_CTYPE: en_US.UTF-8
240+
LOCALE_ARCHIVE: /usr/lib/locale/locale-archive
241+
vars:
242+
ansible_command_timeout: 60
243+
when: stage2_nix and is_psql_oriole
224244

225245
- name: copy PG systemd unit
226246
template:

ansible/tasks/stage2-setup-postgres.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@
2525
/etc/postgresql-custom/supautils.conf
2626
when: is_psql_oriole and stage2_nix
2727
become: yes
28+
2829
- name: Remove db_user_namespace from postgresql.conf if oriole-xx build
2930
ansible.builtin.command:
3031
cmd: >
3132
sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;'
3233
/etc/postgresql/postgresql.conf
3334
when: is_psql_oriole and stage2_nix
3435
become: yes
36+
3537
- name: Append orioledb to shared_preload_libraries append within closing quote
3638
ansible.builtin.command:
3739
cmd: >
3840
sed -i 's/\(shared_preload_libraries.*\)'\''\(.*\)$/\1, orioledb'\''\2/'
3941
/etc/postgresql/postgresql.conf
4042
when: is_psql_oriole and stage2_nix
4143
become: yes
44+
4245
- name: Add default_table_access_method setting
4346
ansible.builtin.lineinfile:
4447
path: /etc/postgresql/postgresql.conf
@@ -47,6 +50,18 @@
4750
when: is_psql_oriole and stage2_nix
4851
become: yes
4952

53+
- name: Add ICU locale settings
54+
ansible.builtin.lineinfile:
55+
path: /etc/postgresql/postgresql.conf
56+
line: "{{ item }}"
57+
state: present
58+
with_items:
59+
- "lc_collate = 'en-US-x-icu'"
60+
- "lc_ctype = 'en-US-x-icu'"
61+
- "icu_locale = 'en-US'"
62+
when: is_psql_oriole and stage2_nix
63+
become: yes
64+
5065
- name: Install Git for Nix package management
5166
become: yes
5267
apt:

0 commit comments

Comments
 (0)