Skip to content

Commit 7d4bbf0

Browse files
authored
refactor: Standardize WAL-G config inclusion (#1965)
* refactor: Move read-replica.conf to conf.d The `read-replica.conf` file has been moved from `/etc/postgresql-custom/` to `/etc/postgresql-custom/conf.d/`. This change aligns with the standard practice of including configuration snippets from a `conf.d` directory. Changes include: - Dockerfiles: Adjusted to remove direct copy and update `sed` commands. - Ansible: Renamed configuration file and updated task to place it in `conf.d`. - Nix: Updated paths and substitutions to reflect the new location. * chore: Update postgres and pgbouncer versions Updates the following versions for improved security and stability: - PostgreSQL 17 (orioledb-17) to 17.6.0.015 - PostgreSQL 17 to 17.6.1.058 - PostgreSQL 15 to 15.14.1.058 Also updates the checksum for Pgbouncer 1.19.0. * refactor: Standardize WAL-G config inclusion depends on #1956 - WAL-G configuration is now managed by placing `wal-g.conf` in `/etc/postgresql-custom/conf.d/`. - This aligns with PostgreSQL's standard practice of including configuration files from `conf.d` subdirectories. - Direct inclusion of `wal-g.conf` in `postgresql.conf` has been removed. - PostgreSQL `archive_mode` is now explicitly set to `on` with a no-op `archive_command` in `postgresql.conf.j2`.
1 parent 1d4af35 commit 7d4bbf0

File tree

6 files changed

+20
-37
lines changed

6 files changed

+20
-37
lines changed

Dockerfile-15

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,14 @@ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout
214214
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf
215215
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
216216
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
217-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf
218217
COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh
219218
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
220219

221220
RUN sed -i \
222221
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
223222
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
224223
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
225-
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
224+
/etc/postgresql/postgresql.conf && \
226225
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
227226
echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
228227
usermod -aG postgres wal-g && \

Dockerfile-17

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,14 @@ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout
218218
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf
219219
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
220220
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
221-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf
222221
COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh
223222
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
224223

225224
RUN sed -i \
226225
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
227226
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
228227
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
229-
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
228+
/etc/postgresql/postgresql.conf && \
230229
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
231230
echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
232231
usermod -aG postgres wal-g && \

Dockerfile-orioledb-17

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,14 @@ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout
218218
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf
219219
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
220220
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
221-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf
222221
COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh
223222
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
224223

225224
RUN sed -i \
226225
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
227226
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
228227
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
229-
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
228+
/etc/postgresql/postgresql.conf && \
230229
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
231230
echo "vault.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
232231
usermod -aG postgres wal-g && \
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# - Archiving -
22

3-
#archive_mode = on
43
#archive_command = '/usr/bin/admin-mgr wal-push %p >> /var/log/wal-g/wal-push.log 2>&1'
54
#archive_timeout = 120
65

76

8-
# - Archive Recovery -
9-
10-
#restore_command = '/usr/bin/admin-mgr wal-fetch %f %p >> /var/log/wal-g/wal-fetch.log 2>&1'
7+
# - Hot Standby -
8+
hot_standby = off
119

1210
# - Recovery Target -
1311

12+
#recovery_target_action = 'promote'
13+
#recovery_target_inclusive = off
1414
#recovery_target_lsn = ''
1515
#recovery_target_time = ''
16-
#recovery_target_action = 'promote'
1716
#recovery_target_timeline = 'current'
18-
#recovery_target_inclusive = off
1917

20-
# - Hot Standby -
21-
hot_standby = off
18+
#restore_command = '/usr/bin/admin-mgr wal-fetch %f %p >> /var/log/wal-g/wal-fetch.log 2>&1'

ansible/files/postgresql_config/postgresql.conf.j2

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,11 @@ checkpoint_flush_after = 256kB # measured in pages, 0 disables
242242

243243
# - Archiving -
244244

245-
#archive_mode = off # enables archiving; off, on, or always
246-
# (change requires restart)
247-
#archive_command = '' # command to use to archive a logfile segment
248-
# placeholders: %p = path of file to archive
249-
# %f = file name only
250-
# e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
245+
archive_mode = on # enables archiving; off, on, or always (change requires restart)
246+
archive_command = '/bin/true' # command to use to archive a logfile segment
247+
# placeholders: %p = path of file to archive
248+
# %f = file name only
249+
# e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
251250
#archive_timeout = 0 # force a logfile segment switch after this
252251
# number of seconds; 0 disables
253252

@@ -758,9 +757,6 @@ jit_provider = 'llvmjit' # JIT library to use
758757
# User-supplied custom parameters, override any automatically generated ones
759758
#include = '/etc/postgresql-custom/custom-overrides.conf'
760759

761-
# WAL-G specific configurations
762-
#include = '/etc/postgresql-custom/wal-g.conf'
763-
764760
# supautils specific configurations
765761
#include = '/etc/postgresql-custom/supautils.conf'
766762

ansible/tasks/setup-wal-g.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@
5454
path: '/etc/wal-g/config.json'
5555
state: 'touch'
5656

57-
- name: Move custom wal-g.conf file to /etc/postgresql-custom/wal-g.conf
58-
ansible.builtin.template:
59-
dest: '/etc/postgresql-custom/wal-g.conf'
60-
group: 'postgres'
61-
mode: '0664'
62-
owner: 'postgres'
63-
src: 'files/postgresql_config/custom_walg.conf.j2'
64-
6557
- name: Add script to be run for restore_command
6658
ansible.builtin.template:
6759
dest: '/home/postgres/wal_fetch.sh'
@@ -77,9 +69,10 @@
7769
owner: 'root'
7870
src: 'files/walg_helper_scripts/wal_change_ownership.sh'
7971

80-
- name: Include /etc/postgresql-custom/wal-g.conf in postgresql.conf
81-
ansible.builtin.replace:
82-
path: '/etc/postgresql/postgresql.conf'
83-
regexp: "#include = '/etc/postgresql-custom/wal-g.conf'"
84-
replace: "include = '/etc/postgresql-custom/wal-g.conf'"
85-
become: true
72+
- name: Move custom wal-g.conf file to /etc/postgresql-custom/conf.d/wal-g.conf
73+
ansible.builtin.copy:
74+
dest: '/etc/postgresql-custom/conf.d/wal-g.conf'
75+
group: 'postgres'
76+
mode: '0664'
77+
owner: 'postgres'
78+
src: 'files/postgresql_config/conf.d/wal-g.conf'

0 commit comments

Comments
 (0)