From 68baaddb52121359284a3128954bc133bac956ca Mon Sep 17 00:00:00 2001 From: Douglas J Hunley Date: Tue, 2 Dec 2025 13:30:49 -0500 Subject: [PATCH] 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. --- Dockerfile-15 | 1 - Dockerfile-17 | 1 - Dockerfile-orioledb-17 | 1 - .../read_replica.conf} | 5 +++-- ansible/files/postgresql_config/postgresql.conf.j2 | 3 --- ansible/tasks/setup-postgres.yml | 8 ++++---- nix/packages/lib.nix | 6 ------ nix/tools/run-server.sh.in | 1 - 8 files changed, 7 insertions(+), 19 deletions(-) rename ansible/files/postgresql_config/{custom_read_replica.conf.j2 => conf.d/read_replica.conf} (99%) diff --git a/Dockerfile-15 b/Dockerfile-15 index 62e0308df..f4af30efa 100644 --- a/Dockerfile-15 +++ b/Dockerfile-15 @@ -214,7 +214,6 @@ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh -COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/read-replica.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh diff --git a/Dockerfile-17 b/Dockerfile-17 index 6c2f1c6bf..d56f57da7 100644 --- a/Dockerfile-17 +++ b/Dockerfile-17 @@ -218,7 +218,6 @@ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh -COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/read-replica.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh diff --git a/Dockerfile-orioledb-17 b/Dockerfile-orioledb-17 index b242a8527..422056f7a 100644 --- a/Dockerfile-orioledb-17 +++ b/Dockerfile-orioledb-17 @@ -218,7 +218,6 @@ COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh -COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/read-replica.conf COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh diff --git a/ansible/files/postgresql_config/custom_read_replica.conf.j2 b/ansible/files/postgresql_config/conf.d/read_replica.conf similarity index 99% rename from ansible/files/postgresql_config/custom_read_replica.conf.j2 rename to ansible/files/postgresql_config/conf.d/read_replica.conf index 7d52f92a7..aa4fcc4d9 100644 --- a/ansible/files/postgresql_config/custom_read_replica.conf.j2 +++ b/ansible/files/postgresql_config/conf.d/read_replica.conf @@ -1,5 +1,6 @@ # hot_standby = on -# restore_command = '/usr/bin/admin-mgr wal-fetch %f %p >> /var/log/wal-g/wal-fetch.log 2>&1' -# recovery_target_timeline = 'latest' # primary_conninfo = 'host=localhost port=6543 user=replication' + +# restore_command = '/usr/bin/admin-mgr wal-fetch %f %p >> /var/log/wal-g/wal-fetch.log 2>&1' +# recovery_target_timeline = 'latest' diff --git a/ansible/files/postgresql_config/postgresql.conf.j2 b/ansible/files/postgresql_config/postgresql.conf.j2 index 915e3677b..04378c3a4 100644 --- a/ansible/files/postgresql_config/postgresql.conf.j2 +++ b/ansible/files/postgresql_config/postgresql.conf.j2 @@ -761,9 +761,6 @@ jit_provider = 'llvmjit' # JIT library to use # WAL-G specific configurations #include = '/etc/postgresql-custom/wal-g.conf' -# read replica specific configurations -include = '/etc/postgresql-custom/read-replica.conf' - # supautils specific configurations #include = '/etc/postgresql-custom/supautils.conf' diff --git a/ansible/tasks/setup-postgres.yml b/ansible/tasks/setup-postgres.yml index 16e83eea2..465117031 100644 --- a/ansible/tasks/setup-postgres.yml +++ b/ansible/tasks/setup-postgres.yml @@ -167,13 +167,13 @@ loop_control: loop_var: 'pg_config_item' - - name: Move custom read-replica.conf file to /etc/postgresql-custom/read-replica.conf - ansible.builtin.template: - dest: '/etc/postgresql-custom/read-replica.conf' + - name: Move read-replica.conf file to /etc/postgresql-custom/conf.d/read-replica.conf + ansible.builtin.copy: + dest: '/etc/postgresql-custom/conf.d/read_replica.conf' mode: '0664' owner: 'postgres' group: 'postgres' - src: 'files/postgresql_config/custom_read_replica.conf.j2' + src: 'files/postgresql_config/conf.d/read_replica.conf' # Install extensions before init - name: Install Postgres extensions diff --git a/nix/packages/lib.nix b/nix/packages/lib.nix index 505eded02..cf541913d 100644 --- a/nix/packages/lib.nix +++ b/nix/packages/lib.nix @@ -48,10 +48,6 @@ name = "logging.conf"; path = ../../ansible/files/postgresql_config/postgresql-csvlog.conf; }; - readReplicaConfigFile = builtins.path { - name = "readreplica.conf"; - path = ../../ansible/files/postgresql_config/custom_read_replica.conf.j2; - }; pgHbaConfigFile = builtins.path { name = "pg_hba.conf"; path = ../../ansible/files/postgresql_config/pg_hba.conf.j2; @@ -91,7 +87,6 @@ POSTGRESQL_CONFIG_DIR = "${postgresqlConfigBaseDir}"; PSQLORIOLEDB17_BINDIR = "${psql_orioledb-17}"; PGSODIUM_GETKEY = "${paths.getkeyScript}"; - READREPL_CONF_FILE = "${paths.readReplicaConfigFile}"; LOGGING_CONF_FILE = "${paths.loggingConfigFile}"; SUPAUTILS_CONF_FILE = "${paths.supautilsConfigFile}"; PG_HBA = "${paths.pgHbaConfigFile}"; @@ -123,7 +118,6 @@ cp ${paths.supautilsConfigFile} $out/etc/postgresql-custom/supautils.conf || { echo "Failed to copy supautils.conf"; exit 1; } cp ${paths.pgconfigFile} $out/etc/postgresql/postgresql.conf || { echo "Failed to copy postgresql.conf"; exit 1; } cp ${paths.loggingConfigFile} $out/etc/postgresql-custom/logging.conf || { echo "Failed to copy logging.conf"; exit 1; } - cp ${paths.readReplicaConfigFile} $out/etc/postgresql-custom/read-replica.conf || { echo "Failed to copy read-replica.conf"; exit 1; } cp ${paths.pgHbaConfigFile} $out/etc/postgresql/pg_hba.conf || { echo "Failed to copy pg_hba.conf"; exit 1; } cp ${paths.pgIdentConfigFile} $out/etc/postgresql/pg_ident.conf || { echo "Failed to copy pg_ident.conf"; exit 1; } cp -r ${paths.postgresqlExtensionCustomScriptsPath}/* $out/extension-custom-scripts/ || { echo "Failed to copy custom scripts"; exit 1; } diff --git a/nix/tools/run-server.sh.in b/nix/tools/run-server.sh.in index 48ce41d26..5cd86fe31 100644 --- a/nix/tools/run-server.sh.in +++ b/nix/tools/run-server.sh.in @@ -240,7 +240,6 @@ vault.getkey_script = '$PGSODIUM_GETKEY_SCRIPT'" \ -e "s|hba_file = '/etc/postgresql/pg_hba.conf'|hba_file = '$DATDIR/pg_hba.conf'|" \ -e "s|ident_file = '/etc/postgresql/pg_ident.conf'|ident_file = '$DATDIR/pg_ident.conf'|" \ -e "s|include = '/etc/postgresql/logging.conf'|#&|" \ --e "s|include = '/etc/postgresql-custom/read-replica.conf'|include = '$DATDIR/read-replica.conf'|" \ -e "\$a\\ session_preload_libraries = 'supautils'" \ -e "s|include_dir = '/etc/postgresql-custom/conf.d'|include_dir = '$DATDIR/conf.d'|" \