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/mongodb] Create replicaset keyFile before mongo starts #32665

Merged
merged 4 commits into from
Aug 3, 2023
Merged
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 @@ -1397,6 +1397,15 @@ mongodb_initialize() {
mongodb_set_storage_conf "$MONGODB_CONF_FILE"
is_boolean_yes "$MONGODB_DISABLE_JAVASCRIPT" && mongodb_disable_javascript_conf "$MONGODB_CONF_FILE"

# Create the ReplicaSet keyFile before Mongo starts in case it is referenced in the $MONGODB_CONF_FILE
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]]; then
if [[ -n "$MONGODB_REPLICA_SET_KEY" ]]; then
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf "$MONGODB_CONF_FILE"
fi
mongodb_set_replicasetmode_conf "$MONGODB_CONF_FILE"
fi

if is_dir_empty "$MONGODB_DATA_DIR/db"; then
info "Deploying MongoDB from scratch..."
ensure_dir_exists "$MONGODB_DATA_DIR/db"
Expand All @@ -1405,11 +1414,6 @@ mongodb_initialize() {
mongodb_start_bg "$MONGODB_CONF_FILE"
mongodb_create_users
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]]; then
if [[ -n "$MONGODB_REPLICA_SET_KEY" ]]; then
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf "$MONGODB_CONF_FILE"
fi
mongodb_set_replicasetmode_conf "$MONGODB_CONF_FILE"
mongodb_set_listen_all_conf "$MONGODB_CONF_FILE"
mongodb_configure_replica_set
fi
Expand All @@ -1418,15 +1422,8 @@ mongodb_initialize() {
else
mongodb_set_auth_conf "$MONGODB_CONF_FILE"
info "Deploying MongoDB with persisted data..."
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]]; then
if [[ -n "$MONGODB_REPLICA_SET_KEY" ]]; then
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf "$MONGODB_CONF_FILE"
fi
if [[ "$MONGODB_REPLICA_SET_MODE" = "dynamic" ]]; then
mongodb_ensure_dynamic_mode_consistency
fi
mongodb_set_replicasetmode_conf "$MONGODB_CONF_FILE"
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]] && [[ "$MONGODB_REPLICA_SET_MODE" = "dynamic" ]]; then
mongodb_ensure_dynamic_mode_consistency
fi
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,15 @@ mongodb_initialize() {
mongodb_set_storage_conf "$MONGODB_CONF_FILE"
is_boolean_yes "$MONGODB_DISABLE_JAVASCRIPT" && mongodb_disable_javascript_conf "$MONGODB_CONF_FILE"

# Create the ReplicaSet keyFile before Mongo starts in case it is referenced in the $MONGODB_CONF_FILE
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]]; then
if [[ -n "$MONGODB_REPLICA_SET_KEY" ]]; then
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf "$MONGODB_CONF_FILE"
fi
mongodb_set_replicasetmode_conf "$MONGODB_CONF_FILE"
fi

if is_dir_empty "$MONGODB_DATA_DIR/db"; then
info "Deploying MongoDB from scratch..."
ensure_dir_exists "$MONGODB_DATA_DIR/db"
Expand All @@ -1405,11 +1414,6 @@ mongodb_initialize() {
mongodb_start_bg "$MONGODB_CONF_FILE"
mongodb_create_users
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]]; then
if [[ -n "$MONGODB_REPLICA_SET_KEY" ]]; then
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf "$MONGODB_CONF_FILE"
fi
mongodb_set_replicasetmode_conf "$MONGODB_CONF_FILE"
mongodb_set_listen_all_conf "$MONGODB_CONF_FILE"
mongodb_configure_replica_set
fi
Expand All @@ -1418,15 +1422,8 @@ mongodb_initialize() {
else
mongodb_set_auth_conf "$MONGODB_CONF_FILE"
info "Deploying MongoDB with persisted data..."
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]]; then
if [[ -n "$MONGODB_REPLICA_SET_KEY" ]]; then
mongodb_create_keyfile "$MONGODB_REPLICA_SET_KEY"
mongodb_set_keyfile_conf "$MONGODB_CONF_FILE"
fi
if [[ "$MONGODB_REPLICA_SET_MODE" = "dynamic" ]]; then
mongodb_ensure_dynamic_mode_consistency
fi
mongodb_set_replicasetmode_conf "$MONGODB_CONF_FILE"
if [[ -n "$MONGODB_REPLICA_SET_MODE" ]] && [[ "$MONGODB_REPLICA_SET_MODE" = "dynamic" ]]; then
mongodb_ensure_dynamic_mode_consistency
fi
fi

Expand Down
Loading