Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bitnami/postgresql-repmgr] use passfile on primary_conninfo #73542

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,23 @@ postgresql_slave_init_db() {
done
}

########################
# Get postgresql replication user conninfo password method
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# Returns:
# String
#########################
postgresql_replication_get_conninfo_password() {
if [[ "$POSTGRESQL_REPLICATION_USE_PASSFILE" = "true" ]]; then
echo "passfile=${POSTGRESQL_REPLICATION_PASSFILE_PATH}"
else
echo "password=${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
fi
}

########################
# Create recovery.conf in slave node
# Globals:
Expand All @@ -936,18 +953,17 @@ postgresql_slave_init_db() {
postgresql_configure_recovery() {
info "Setting up streaming replication slave..."

local -r escaped_password="${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
local -r psql_major_version="$(postgresql_get_major_version)"
if ((psql_major_version >= 12)); then
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
((psql_major_version < 16)) && postgresql_set_property "promote_trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_CONF_FILE"
touch "$POSTGRESQL_DATA_DIR"/standby.signal
else
cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE"
chmod 600 "$POSTGRESQL_RECOVERY_FILE"
am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE"
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-10}"
export POSTGRESQL_REPLICATION_USER="$REPMGR_USERNAME"
export POSTGRESQL_REPLICATION_PASSWORD="$REPMGR_PASSWORD"
export POSTGRESQL_REPLICATION_USE_PASSFILE="$REPMGR_USE_PASSFILE"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${POSTGRESQL_REPLICATION_PASSFILE_PATH:-$REPMGR_PASSFILE_PATH}"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${REPMGR_PASSFILE_PATH}"
export POSTGRESQL_MASTER_HOST="$REPMGR_PRIMARY_HOST"
export POSTGRESQL_MASTER_PORT_NUMBER="$REPMGR_PRIMARY_PORT"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,23 @@ postgresql_slave_init_db() {
done
}

########################
# Get postgresql replication user conninfo password method
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# Returns:
# String
#########################
postgresql_replication_get_conninfo_password() {
if [[ "$POSTGRESQL_REPLICATION_USE_PASSFILE" = "true" ]]; then
echo "passfile=${POSTGRESQL_REPLICATION_PASSFILE_PATH}"
else
echo "password=${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
fi
}

########################
# Create recovery.conf in slave node
# Globals:
Expand All @@ -936,18 +953,17 @@ postgresql_slave_init_db() {
postgresql_configure_recovery() {
info "Setting up streaming replication slave..."

local -r escaped_password="${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
local -r psql_major_version="$(postgresql_get_major_version)"
if ((psql_major_version >= 12)); then
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
((psql_major_version < 16)) && postgresql_set_property "promote_trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_CONF_FILE"
touch "$POSTGRESQL_DATA_DIR"/standby.signal
else
cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE"
chmod 600 "$POSTGRESQL_RECOVERY_FILE"
am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE"
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-10}"
export POSTGRESQL_REPLICATION_USER="$REPMGR_USERNAME"
export POSTGRESQL_REPLICATION_PASSWORD="$REPMGR_PASSWORD"
export POSTGRESQL_REPLICATION_USE_PASSFILE="$REPMGR_USE_PASSFILE"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${POSTGRESQL_REPLICATION_PASSFILE_PATH:-$REPMGR_PASSFILE_PATH}"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${REPMGR_PASSFILE_PATH}"
export POSTGRESQL_MASTER_HOST="$REPMGR_PRIMARY_HOST"
export POSTGRESQL_MASTER_PORT_NUMBER="$REPMGR_PRIMARY_PORT"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,23 @@ postgresql_slave_init_db() {
done
}

########################
# Get postgresql replication user conninfo password method
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# Returns:
# String
#########################
postgresql_replication_get_conninfo_password() {
if [[ "$POSTGRESQL_REPLICATION_USE_PASSFILE" = "true" ]]; then
echo "passfile=${POSTGRESQL_REPLICATION_PASSFILE_PATH}"
else
echo "password=${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
fi
}

########################
# Create recovery.conf in slave node
# Globals:
Expand All @@ -936,18 +953,17 @@ postgresql_slave_init_db() {
postgresql_configure_recovery() {
info "Setting up streaming replication slave..."

local -r escaped_password="${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
local -r psql_major_version="$(postgresql_get_major_version)"
if ((psql_major_version >= 12)); then
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
((psql_major_version < 16)) && postgresql_set_property "promote_trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_CONF_FILE"
touch "$POSTGRESQL_DATA_DIR"/standby.signal
else
cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE"
chmod 600 "$POSTGRESQL_RECOVERY_FILE"
am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE"
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-10}"
export POSTGRESQL_REPLICATION_USER="$REPMGR_USERNAME"
export POSTGRESQL_REPLICATION_PASSWORD="$REPMGR_PASSWORD"
export POSTGRESQL_REPLICATION_USE_PASSFILE="$REPMGR_USE_PASSFILE"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${POSTGRESQL_REPLICATION_PASSFILE_PATH:-$REPMGR_PASSFILE_PATH}"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${REPMGR_PASSFILE_PATH}"
export POSTGRESQL_MASTER_HOST="$REPMGR_PRIMARY_HOST"
export POSTGRESQL_MASTER_PORT_NUMBER="$REPMGR_PRIMARY_PORT"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,23 @@ postgresql_slave_init_db() {
done
}

########################
# Get postgresql replication user conninfo password method
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# Returns:
# String
#########################
postgresql_replication_get_conninfo_password() {
if [[ "$POSTGRESQL_REPLICATION_USE_PASSFILE" = "true" ]]; then
echo "passfile=${POSTGRESQL_REPLICATION_PASSFILE_PATH}"
else
echo "password=${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
fi
}

########################
# Create recovery.conf in slave node
# Globals:
Expand All @@ -936,18 +953,17 @@ postgresql_slave_init_db() {
postgresql_configure_recovery() {
info "Setting up streaming replication slave..."

local -r escaped_password="${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
local -r psql_major_version="$(postgresql_get_major_version)"
if ((psql_major_version >= 12)); then
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
((psql_major_version < 16)) && postgresql_set_property "promote_trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_CONF_FILE"
touch "$POSTGRESQL_DATA_DIR"/standby.signal
else
cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE"
chmod 600 "$POSTGRESQL_RECOVERY_FILE"
am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE"
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-10}"
export POSTGRESQL_REPLICATION_USER="$REPMGR_USERNAME"
export POSTGRESQL_REPLICATION_PASSWORD="$REPMGR_PASSWORD"
export POSTGRESQL_REPLICATION_USE_PASSFILE="$REPMGR_USE_PASSFILE"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${POSTGRESQL_REPLICATION_PASSFILE_PATH:-$REPMGR_PASSFILE_PATH}"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${REPMGR_PASSFILE_PATH}"
export POSTGRESQL_MASTER_HOST="$REPMGR_PRIMARY_HOST"
export POSTGRESQL_MASTER_PORT_NUMBER="$REPMGR_PRIMARY_PORT"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,23 @@ postgresql_slave_init_db() {
done
}

########################
# Get postgresql replication user conninfo password method
# Globals:
# POSTGRESQL_*
# Arguments:
# None
# Returns:
# String
#########################
postgresql_replication_get_conninfo_password() {
if [[ "$POSTGRESQL_REPLICATION_USE_PASSFILE" = "true" ]]; then
echo "passfile=${POSTGRESQL_REPLICATION_PASSFILE_PATH}"
else
echo "password=${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
fi
}

########################
# Create recovery.conf in slave node
# Globals:
Expand All @@ -936,18 +953,17 @@ postgresql_slave_init_db() {
postgresql_configure_recovery() {
info "Setting up streaming replication slave..."

local -r escaped_password="${POSTGRESQL_REPLICATION_PASSWORD//\&/\\&}"
local -r psql_major_version="$(postgresql_get_major_version)"
if ((psql_major_version >= 12)); then
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_CONF_FILE"
((psql_major_version < 16)) && postgresql_set_property "promote_trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_CONF_FILE"
touch "$POSTGRESQL_DATA_DIR"/standby.signal
else
cp -f "$POSTGRESQL_BASE_DIR/share/recovery.conf.sample" "$POSTGRESQL_RECOVERY_FILE"
chmod 600 "$POSTGRESQL_RECOVERY_FILE"
am_i_root && chown "$POSTGRESQL_DAEMON_USER:$POSTGRESQL_DAEMON_GROUP" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "standby_mode" "on" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} password=${escaped_password} application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "primary_conninfo" "host=${POSTGRESQL_MASTER_HOST} port=${POSTGRESQL_MASTER_PORT_NUMBER} user=${POSTGRESQL_REPLICATION_USER} $(postgresql_replication_get_conninfo_password) application_name=${POSTGRESQL_CLUSTER_APP_NAME}" "$POSTGRESQL_RECOVERY_FILE"
postgresql_set_property "trigger_file" "/tmp/postgresql.trigger.${POSTGRESQL_MASTER_PORT_NUMBER}" "$POSTGRESQL_RECOVERY_FILE"
fi
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export PGCONNECT_TIMEOUT="${PGCONNECT_TIMEOUT:-10}"
export POSTGRESQL_REPLICATION_USER="$REPMGR_USERNAME"
export POSTGRESQL_REPLICATION_PASSWORD="$REPMGR_PASSWORD"
export POSTGRESQL_REPLICATION_USE_PASSFILE="$REPMGR_USE_PASSFILE"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${POSTGRESQL_REPLICATION_PASSFILE_PATH:-$REPMGR_PASSFILE_PATH}"
export POSTGRESQL_REPLICATION_PASSFILE_PATH="${REPMGR_PASSFILE_PATH}"
export POSTGRESQL_MASTER_HOST="$REPMGR_PRIMARY_HOST"
export POSTGRESQL_MASTER_PORT_NUMBER="$REPMGR_PRIMARY_PORT"

Expand Down
Loading
Loading