[bitnami/postgresql-repmgr] Release 17.4.0-debian-12-r17 (#80877)

Signed-off-by: Bitnami Bot <bitnami.bot@broadcom.com>
This commit is contained in:
Bitnami Bot
2025-05-07 19:40:21 +02:00
committed by GitHub
parent f83f4e116e
commit dd1159fac4
6 changed files with 115 additions and 36 deletions

View File

@@ -8,10 +8,10 @@ ARG TARGETARCH
LABEL com.vmware.cp.artifact.flavor="sha256:c50c90cfd9d12b445b011e6ad529f1ad3daea45c26d20b00732fae3cd71f6a83" \
org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \
org.opencontainers.image.created="2025-04-15T02:21:03Z" \
org.opencontainers.image.created="2025-05-07T16:29:24Z" \
org.opencontainers.image.description="Application packaged by Broadcom, Inc." \
org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/postgresql-repmgr/README.md" \
org.opencontainers.image.ref.name="17.4.0-debian-12-r16" \
org.opencontainers.image.ref.name="17.4.0-debian-12-r17" \
org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/postgresql-repmgr" \
org.opencontainers.image.title="postgresql-repmgr" \
org.opencontainers.image.vendor="Broadcom, Inc." \

View File

@@ -83,6 +83,9 @@ postgresql_validate() {
if [[ -n "$POSTGRESQL_USERNAME" ]] && [[ "$POSTGRESQL_USERNAME" != "postgres" ]] && [[ -n "$POSTGRESQL_PASSWORD" ]] && [[ -z "$POSTGRESQL_DATABASE" ]]; then
print_validation_error "In order to use a custom PostgreSQL user you need to set the environment variable POSTGRESQL_DATABASE as well"
fi
if is_boolean_yes "$POSTGRESQL_SR_CHECK" && [[ -z "$POSTGRESQL_SR_CHECK_PASSWORD" ]]; then
empty_password_error "POSTGRESQL_SR_CHECK_PASSWORD"
fi
fi
if [[ -n "$POSTGRESQL_REPLICATION_MODE" ]]; then
if [[ "$POSTGRESQL_REPLICATION_MODE" = "master" ]]; then
@@ -124,6 +127,12 @@ postgresql_validate() {
empty_password_error "You can not set POSTGRESQL_LDAP_URL and POSTGRESQL_LDAP_SERVER at the same time. Check your LDAP configuration."
fi
if ! is_yes_no_value "$POSTGRESQL_SR_CHECK"; then
print_validation_error "The values allowed for POSTGRESQL_SR_CHECK are: yes or no"
elif is_boolean_yes "$POSTGRESQL_SR_CHECK" && [[ -z "$POSTGRESQL_SR_CHECK_USERNAME" || -z "$POSTGRESQL_SR_CHECK_DATABASE" ]]; then
print_validation_error "The environment variables POSTGRESQL_SR_CHECK_USERNAME and POSTGRESQL_SR_CHECK_DATABASE are required when using the SR_CHECK feature"
fi
if ! is_yes_no_value "$POSTGRESQL_ENABLE_TLS"; then
print_validation_error "The values allowed for POSTGRESQL_ENABLE_TLS are: yes or no"
elif is_boolean_yes "$POSTGRESQL_ENABLE_TLS"; then
@@ -311,7 +320,7 @@ postgresql_restrict_pghba() {
}
########################
# Change pg_hba.conf so it allows access from replication users
# Change pg_hba.conf so it allows access from replication user
# Globals:
# POSTGRESQL_*
# Arguments:
@@ -330,6 +339,26 @@ host replication all ::/0 ${replication_
EOF
}
########################
# Change pg_hba.conf so it allows access from sr_check user
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# Returns:
# None
#########################
postgresql_add_sr_check_user_to_pghba() {
local sr_check_auth="trust"
if [[ -n "$POSTGRESQL_SR_CHECK_PASSWORD" ]]; then
sr_check_auth="md5"
fi
cat <<EOF >>"$POSTGRESQL_PGHBA_FILE"
host $POSTGRESQL_SR_CHECK_DATABASE $POSTGRESQL_SR_CHECK_USERNAME 0.0.0.0/0 ${sr_check_auth}
host $POSTGRESQL_SR_CHECK_DATABASE $POSTGRESQL_SR_CHECK_USERNAME ::/0 ${sr_check_auth}
EOF
}
########################
# Change a PostgreSQL configuration file by setting a property
# Globals:
@@ -354,7 +383,7 @@ postgresql_set_property() {
}
########################
# Create a user for master-slave replication
# Create a user for primary-replica replication
# Globals:
# POSTGRESQL_*
# Arguments:
@@ -370,6 +399,29 @@ postgresql_create_replication_user() {
echo "CREATE ROLE \"$POSTGRESQL_REPLICATION_USER\" REPLICATION LOGIN ENCRYPTED PASSWORD '$escaped_password'" | postgresql_execute "" "postgres" "$postgres_password"
}
########################
# Create a user for Stream Replication checks
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# Returns:
# None
#########################
postgresql_create_sr_check_user() {
local -r escaped_password="${POSTGRESQL_SR_CHECK_PASSWORD//\'/\'\'}"
local -r postgres_password="${POSTGRESQL_POSTGRES_PASSWORD:-$POSTGRESQL_PASSWORD}"
if [[ -n "$POSTGRESQL_REPLICATION_USER" ]] && [[ "$POSTGRESQL_SR_CHECK_USERNAME" == "$POSTGRESQL_REPLICATION_USER" ]]; then
debug "The SR_CHECK username is the same as the replication user, skipping creation"
else
info "Creating sr-check user $POSTGRESQL_SR_CHECK_USERNAME"
echo "CREATE ROLE \"${POSTGRESQL_SR_CHECK_USERNAME}\" WITH LOGIN PASSWORD '${escaped_password}';" | postgresql_execute "" "postgres" "$postgres_password"
fi
info "Granting access to \"${POSTGRESQL_SR_CHECK_USERNAME}\" to the database \"${POSTGRESQL_SR_CHECK_DATABASE}\""
echo "GRANT CONNECT ON DATABASE \"${POSTGRESQL_SR_CHECK_DATABASE}\" TO \"${POSTGRESQL_SR_CHECK_USERNAME}\"\;" | postgresql_execute "" "postgres" "$postgres_password"
}
########################
# Change postgresql.conf by setting replication parameters
# Globals:
@@ -522,12 +574,13 @@ postgresql_create_admin_user() {
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# $1 - Database name
# Returns:
# None
#########################
postgresql_create_custom_database() {
echo "CREATE DATABASE \"$POSTGRESQL_DATABASE\"" | postgresql_execute "" "postgres" ""
local -r db_name="${1:?missing database}"
echo "CREATE DATABASE \"$db_name\"" | postgresql_execute "" "postgres" ""
}
########################
@@ -650,7 +703,8 @@ postgresql_initialize() {
if [[ "$POSTGRESQL_REPLICATION_MODE" = "master" ]]; then
postgresql_master_init_db
postgresql_start_bg "false"
[[ -n "${POSTGRESQL_DATABASE}" ]] && [[ "$POSTGRESQL_DATABASE" != "postgres" ]] && postgresql_create_custom_database
[[ -n "$POSTGRESQL_DATABASE" ]] && [[ "$POSTGRESQL_DATABASE" != "postgres" ]] && postgresql_create_custom_database "$POSTGRESQL_DATABASE"
is_boolean_yes "$POSTGRESQL_SR_CHECK" && [[ "$POSTGRESQL_SR_CHECK_DATABASE" != "postgres" ]] && postgresql_create_custom_database "$POSTGRESQL_SR_CHECK_DATABASE"
if [[ "$POSTGRESQL_USERNAME" = "postgres" ]]; then
postgresql_alter_postgres_user "$POSTGRESQL_PASSWORD"
else
@@ -660,16 +714,17 @@ postgresql_initialize() {
postgresql_create_admin_user
fi
is_boolean_yes "$create_pghba_file" && postgresql_restrict_pghba
is_boolean_yes "$POSTGRESQL_SR_CHECK" && postgresql_create_sr_check_user
[[ -n "$POSTGRESQL_REPLICATION_USER" ]] && ! $skip_replication && postgresql_create_replication_user
is_boolean_yes "$create_conf_file" && ! $skip_replication && postgresql_configure_replication_parameters
is_boolean_yes "$create_pghba_file" && ! $skip_replication && postgresql_configure_synchronous_replication
is_boolean_yes "$create_pghba_file" && ! $skip_replication && postgresql_configure_synchronous_replication
is_boolean_yes "$create_conf_file" && postgresql_configure_fsync
is_boolean_yes "$create_conf_file" && is_boolean_yes "$POSTGRESQL_ENABLE_TLS" && postgresql_configure_tls
[[ -n "$POSTGRESQL_REPLICATION_USER" ]] && is_boolean_yes "$create_pghba_file" && ! $skip_replication && postgresql_add_replication_to_pghba
else
postgresql_slave_init_db
is_boolean_yes "$create_pghba_file" && postgresql_restrict_pghba
is_boolean_yes "$create_conf_file" && ! $skip_replication && postgresql_configure_replication_parameters
is_boolean_yes "$create_conf_file" && ! $skip_replication && postgresql_configure_replication_parameters
is_boolean_yes "$create_conf_file" && postgresql_configure_fsync
is_boolean_yes "$create_conf_file" && is_boolean_yes "$POSTGRESQL_ENABLE_TLS" && postgresql_configure_tls
! $skip_replication && postgresql_configure_recovery
@@ -677,6 +732,8 @@ postgresql_initialize() {
fi
# TLS Modifications on pghba need to be performed after properly configuring postgresql.conf file
is_boolean_yes "$create_pghba_file" && is_boolean_yes "$POSTGRESQL_ENABLE_TLS" && [[ -n $POSTGRESQL_TLS_CA_FILE ]] && postgresql_tls_auth_configuration
# Allow access from sr_check user
is_boolean_yes "$create_pghba_file" && is_boolean_yes "$POSTGRESQL_SR_CHECK" && postgresql_add_sr_check_user_to_pghba
is_boolean_yes "$create_conf_file" && [[ -n "$POSTGRESQL_SHARED_PRELOAD_LIBRARIES" ]] && postgresql_set_property "shared_preload_libraries" "$POSTGRESQL_SHARED_PRELOAD_LIBRARIES"
is_boolean_yes "$create_conf_file" && postgresql_configure_logging

View File

@@ -425,23 +425,30 @@ repmgr_inject_postgresql_configuration() {
#########################
repmgr_inject_pghba_configuration() {
debug "Injecting a new pg_hba.conf file..."
local tls_auth="#"
if is_boolean_yes "$POSTGRESQL_ENABLE_TLS" && [[ -n $POSTGRESQL_TLS_CA_FILE ]]; then
tls_auth=""
fi
cat >"${POSTGRESQL_MOUNTED_CONF_DIR}/pg_hba.conf" <<EOF
host all $REPMGR_USERNAME 0.0.0.0/0 trust
host $REPMGR_DATABASE $REPMGR_USERNAME 0.0.0.0/0 trust
host $REPMGR_DATABASE $REPMGR_USERNAME ::/0 trust
host replication $REPMGR_USERNAME 0.0.0.0/0 trust
host replication $REPMGR_USERNAME ::/0 trust
${tls_auth}hostssl all all 0.0.0.0/0 cert
${tls_auth}hostssl all all ::/0 cert
host all all 0.0.0.0/0 trust
host all all ::/0 trust
local all all trust
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
host all all 0.0.0.0/0 md5
host all all ::/0 md5
host $REPMGR_DATABASE $REPMGR_USERNAME 0.0.0.0/0 md5
host $REPMGR_DATABASE $REPMGR_USERNAME ::/0 md5
host replication all 0.0.0.0/0 md5
host replication all ::/0 md5
EOF
if is_boolean_yes "$POSTGRESQL_SR_CHECK"; then
cat >>"${POSTGRESQL_MOUNTED_CONF_DIR}/pg_hba.conf" <<EOF
host $POSTGRESQL_SR_CHECK_DATABASE $POSTGRESQL_SR_CHECK_USERNAME 0.0.0.0/0 md5
host $POSTGRESQL_SR_CHECK_DATABASE $POSTGRESQL_SR_CHECK_USERNAME ::/0 md5
EOF
fi
if is_boolean_yes "$POSTGRESQL_ENABLE_TLS" && [[ -n $POSTGRESQL_TLS_CA_FILE ]]; then
cat >>"${POSTGRESQL_MOUNTED_CONF_DIR}/pg_hba.conf" <<EOF
hostssl all all 0.0.0.0/0 cert
hostssl all all ::/0 cert
EOF
fi
}
########################

View File

@@ -45,6 +45,9 @@ postgresql_env_vars=(
POSTGRESQL_REPLICATION_USER
POSTGRESQL_REPLICATION_USE_PASSFILE
POSTGRESQL_REPLICATION_PASSFILE_PATH
POSTGRESQL_SR_CHECK
POSTGRESQL_SR_CHECK_USERNAME
POSTGRESQL_SR_CHECK_DATABASE
POSTGRESQL_SYNCHRONOUS_COMMIT_MODE
POSTGRESQL_FSYNC
POSTGRESQL_USERNAME
@@ -65,6 +68,7 @@ postgresql_env_vars=(
POSTGRESQL_PASSWORD
POSTGRESQL_POSTGRES_PASSWORD
POSTGRESQL_REPLICATION_PASSWORD
POSTGRESQL_SR_CHECK_PASSWORD
POSTGRESQL_INITSCRIPTS_PASSWORD
POSTGRESQL_ENABLE_TLS
POSTGRESQL_TLS_CERT_FILE
@@ -154,6 +158,9 @@ postgresql_env_vars=(
POSTGRES_ALLOW_REMOTE_CONNECTIONS
POSTGRES_REPLICATION_MODE
POSTGRES_REPLICATION_USER
POSTGRES_SR_CHECK
POSTGRES_SR_CHECK_USER
POSTGRES_SR_CHECK_DATABASE
POSTGRES_SYNCHRONOUS_COMMIT_MODE
POSTGRES_FSYNC
POSTGRES_USERNAME
@@ -176,6 +183,7 @@ postgresql_env_vars=(
POSTGRES_PASSWORD
POSTGRES_POSTGRES_PASSWORD
POSTGRES_REPLICATION_PASSWORD
POSTGRES_SR_CHECK_PASSWORD
POSTGRES_INITSCRIPTS_PASSWORD
POSTGRES_ENABLE_TLS
POSTGRES_TLS_CERT_FILE
@@ -275,6 +283,12 @@ POSTGRESQL_REPLICATION_USER="${POSTGRESQL_REPLICATION_USER:-"${POSTGRES_REPLICAT
export POSTGRESQL_REPLICATION_USER="${POSTGRESQL_REPLICATION_USER:-}"
export POSTGRESQL_REPLICATION_USE_PASSFILE="${POSTGRESQL_REPLICATION_USE_PASSFILE:-no}"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${POSTGRESQL_REPLICATION_PASSFILE_PATH:-${POSTGRESQL_CONF_DIR}/.pgpass}"
POSTGRESQL_SR_CHECK="${POSTGRESQL_SR_CHECK:-"${POSTGRES_SR_CHECK:-}"}"
export POSTGRESQL_SR_CHECK="${POSTGRESQL_SR_CHECK:-no}"
POSTGRESQL_SR_CHECK_USERNAME="${POSTGRESQL_SR_CHECK_USERNAME:-"${POSTGRES_SR_CHECK_USER:-}"}"
export POSTGRESQL_SR_CHECK_USERNAME="${POSTGRESQL_SR_CHECK_USERNAME:-sr_check_user}"
POSTGRESQL_SR_CHECK_DATABASE="${POSTGRESQL_SR_CHECK_DATABASE:-"${POSTGRES_SR_CHECK_DATABASE:-}"}"
export POSTGRESQL_SR_CHECK_DATABASE="${POSTGRESQL_SR_CHECK_DATABASE:-postgres}"
POSTGRESQL_SYNCHRONOUS_COMMIT_MODE="${POSTGRESQL_SYNCHRONOUS_COMMIT_MODE:-"${POSTGRES_SYNCHRONOUS_COMMIT_MODE:-}"}"
export POSTGRESQL_SYNCHRONOUS_COMMIT_MODE="${POSTGRESQL_SYNCHRONOUS_COMMIT_MODE:-on}"
POSTGRESQL_FSYNC="${POSTGRESQL_FSYNC:-"${POSTGRES_FSYNC:-}"}"
@@ -317,6 +331,8 @@ POSTGRESQL_POSTGRES_PASSWORD="${POSTGRESQL_POSTGRES_PASSWORD:-"${POSTGRES_POSTGR
export POSTGRESQL_POSTGRES_PASSWORD="${POSTGRESQL_POSTGRES_PASSWORD:-}"
POSTGRESQL_REPLICATION_PASSWORD="${POSTGRESQL_REPLICATION_PASSWORD:-"${POSTGRES_REPLICATION_PASSWORD:-}"}"
export POSTGRESQL_REPLICATION_PASSWORD="${POSTGRESQL_REPLICATION_PASSWORD:-}"
POSTGRESQL_SR_CHECK_PASSWORD="${POSTGRESQL_SR_CHECK_PASSWORD:-"${POSTGRES_SR_CHECK_PASSWORD:-}"}"
export POSTGRESQL_SR_CHECK_PASSWORD="${POSTGRESQL_SR_CHECK_PASSWORD:-}"
POSTGRESQL_INITSCRIPTS_PASSWORD="${POSTGRESQL_INITSCRIPTS_PASSWORD:-"${POSTGRES_INITSCRIPTS_PASSWORD:-}"}"
export POSTGRESQL_INITSCRIPTS_PASSWORD="${POSTGRESQL_INITSCRIPTS_PASSWORD:-$POSTGRESQL_PASSWORD}"
POSTGRESQL_ENABLE_TLS="${POSTGRESQL_ENABLE_TLS:-"${POSTGRES_ENABLE_TLS:-}"}"

View File

@@ -34,10 +34,5 @@ repmgr_postgresql_configuration
# Prepare repmgr configuration
repmgr_generate_repmgr_config
# Initialize PostgreSQL & repmgr
export POSTGRESQL_USE_CUSTOM_PGHBA_INITIALIZATION="yes"
repmgr_initialize
# Set custom pg_hba.conf after initialization to avoid conflicts
if postgresql_is_file_external "pg_hba.conf"; then
info "Applying custom $POSTGRESQL_PGHBA_FILE"
cp -f "$POSTGRESQL_MOUNTED_CONF_DIR"/pg_hba.conf "$POSTGRESQL_CONF_DIR"
fi

View File

@@ -571,6 +571,9 @@ Refer to [issues/27124](https://github.com/bitnami/containers/issues/27124) for
| `POSTGRESQL_REPLICATION_USER` | PostgreSQL replication user | `nil` |
| `POSTGRESQL_REPLICATION_USE_PASSFILE` | Use PGPASSFILE instead of PGPASSWORD | `no` |
| `POSTGRESQL_REPLICATION_PASSFILE_PATH` | Path to store passfile | `${POSTGRESQL_CONF_DIR}/.pgpass` |
| `POSTGRESQL_SR_CHECK` | Create user on PostgreSQL for Stream Replication Check | `no` |
| `POSTGRESQL_SR_CHECK_USERNAME` | Stream Replication Check user | `sr_check_user` |
| `POSTGRESQL_SR_CHECK_DATABASE` | Stream Replication Check database | `postgres` |
| `POSTGRESQL_SYNCHRONOUS_COMMIT_MODE` | Enable synchronous replication in slaves (number defined by POSTGRESQL_NUM_SYNCHRONOUS_REPLICAS) | `on` |
| `POSTGRESQL_FSYNC` | Enable fsync in write ahead logs | `on` |
| `POSTGRESQL_USERNAME` | PostgreSQL default username | `postgres` |
@@ -591,6 +594,7 @@ Refer to [issues/27124](https://github.com/bitnami/containers/issues/27124) for
| `POSTGRESQL_PASSWORD` | Password for the PostgreSQL created user | `nil` |
| `POSTGRESQL_POSTGRES_PASSWORD` | Password for the PostgreSQL postgres user | `nil` |
| `POSTGRESQL_REPLICATION_PASSWORD` | Password for the PostgreSQL replication user | `nil` |
| `POSTGRESQL_SR_CHECK_PASSWORD` | Password for the Stream Replication Check user | `nil` |
| `POSTGRESQL_INITSCRIPTS_PASSWORD` | Password for the PostgreSQL init scripts user | `$POSTGRESQL_PASSWORD` |
| `POSTGRESQL_ENABLE_TLS` | Whether to enable TLS for traffic or not | `no` |
| `POSTGRESQL_TLS_CERT_FILE` | File containing the certificate for the TLS traffic | `nil` |
@@ -652,10 +656,10 @@ Refer to [issues/27124](https://github.com/bitnami/containers/issues/27124) for
| `REPMGR_DEGRADED_MONITORING_TIMEOUT` | Replication Manager degraded monitoring timeout | `5` |
| `REPMGR_UPGRADE_EXTENSION` | Replication Manager upgrade extension | `no` |
| `REPMGR_FENCE_OLD_PRIMARY` | Replication Manager fence old primary | `no` |
| `REPMGR_FAILOVER` | Replicatication failover mode | `automatic` |
| `REPMGR_FAILOVER` | Replication failover mode | `automatic` |
| `REPMGR_CHILD_NODES_CHECK_INTERVAL` | Replication Manager time interval to check nodes | `5` |
| `REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT` | Replication Manager minimal connected nodes | `1` |
| `REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT` | Replication Manager disconnected nodes tiemout | `30` |
| `REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT` | Replication Manager disconnected nodes timeout | `30` |
| `REPMGR_SWITCH_ROLE` | Flag to switch current node role | `no` |
| `REPMGR_CURRENT_PRIMARY_HOST` | Current primary host | `nil` |
| `REPMGR_USERNAME` | Replication manager username | `repmgr` |
@@ -707,12 +711,12 @@ Refer to [issues/27124](https://github.com/bitnami/containers/issues/27124) for
| `REPMGR_BIN_DIR` | Replication Manager executables directory | `$REPMGR_BASE_DIR/bin` |
| `REPMGR_CONF_FILE` | Replication Manager configuration file | `$REPMGR_CONF_DIR/repmgr.conf` |
| `REPMGR_CURRENT_PRIMARY_PORT` | Current primary host port | `$REPMGR_PRIMARY_PORT` |
| `POSTGRESQL_REPLICATION_USER` | PostgreSQL connection timeout | `$REPMGR_USERNAME` |
| `POSTGRESQL_REPLICATION_PASSWORD` | PostgreSQL connection timeout | `$REPMGR_PASSWORD` |
| `POSTGRESQL_REPLICATION_USE_PASSFILE` | PostgreSQL use PGPASSFILE instead of PGPASSWORD | `$REPMGR_USE_PASSFILE` |
| `POSTGRESQL_REPLICATION_USER` | PostgreSQL replication user | `$REPMGR_USERNAME` |
| `POSTGRESQL_REPLICATION_PASSWORD` | Password for the PostgreSQL replication user | `$REPMGR_PASSWORD` |
| `POSTGRESQL_REPLICATION_USE_PASSFILE` | Use PGPASSFILE instead of PGPASSWORD | `$REPMGR_USE_PASSFILE` |
| `POSTGRESQL_REPLICATION_PASSFILE_PATH` | Path to store passfile | `$REPMGR_PASSFILE_PATH` |
| `POSTGRESQL_MASTER_HOST` | PostgreSQL connection timeout | `$REPMGR_PRIMARY_HOST` |
| `POSTGRESQL_MASTER_PORT_NUMBER` | PostgreSQL connection timeout | `$REPMGR_PRIMARY_PORT` |
| `POSTGRESQL_MASTER_HOST` | PostgreSQL master host | `$REPMGR_PRIMARY_HOST` |
| `POSTGRESQL_MASTER_PORT_NUMBER` | PostgreSQL master host port | `$REPMGR_PRIMARY_PORT` |
## Logging