Skip to content

Commit

Permalink
Added support for PULP_DEFAULT_ADMIN_PASSWORD
Browse files Browse the repository at this point in the history
The pulp-api script in pulp-minimal now interprets the
PULP_DEFAULT_ADMIN_PASSWORD environment variable in the same way as the
s6 variant.

fixes #417
  • Loading branch information
mdellweg committed Sep 12, 2023
1 parent d714d25 commit cf316c6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES/417.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added logic for ``PULP_DEFAULT_ADMIN_PASSWORD`` to the pulp-minimal startup scripts.
25 changes: 17 additions & 8 deletions images/assets/pulp-api
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@ if [ -n "${PULP_SIGNING_KEY_FINGERPRINT}" ]; then
/usr/local/bin/pulpcore-manager add-signing-service "${CONTAINER_SIGNING_SERVICE}" /var/lib/pulp/scripts/container_sign.sh "${PULP_SIGNING_KEY_FINGERPRINT}" --class container:ManifestSigningService
fi

ADMIN_PASSWORD_FILE=/etc/pulp/pulp-admin-password
if [[ -f "$ADMIN_PASSWORD_FILE" ]]; then
echo "pulp admin can be initialized."
PULP_ADMIN_PASSWORD=$(cat $ADMIN_PASSWORD_FILE)
fi

if [ -n "${PULP_ADMIN_PASSWORD}" ]; then
/usr/local/bin/pulpcore-manager reset-admin-password --password "${PULP_ADMIN_PASSWORD}"
if [[ -n "$PULP_DEFAULT_ADMIN_PASSWORD" ]]
then
PASSWORD_SET=$(/usr/local/bin/pulpcore-manager shell -c "from django.contrib.auth import get_user_model; print(get_user_model().objects.filter(username=\"admin\").exists())")
if [ "$PASSWORD_SET" = "False" ]
then
/usr/local/bin/pulpcore-manager reset-admin-password --password "${PULP_DEFAULT_ADMIN_PASSWORD}"
fi
else
ADMIN_PASSWORD_FILE=/etc/pulp/pulp-admin-password
if [[ -f "$ADMIN_PASSWORD_FILE" ]]; then
echo "pulp admin can be initialized."
PULP_ADMIN_PASSWORD=$(cat $ADMIN_PASSWORD_FILE)
fi

if [ -n "${PULP_ADMIN_PASSWORD}" ]; then
/usr/local/bin/pulpcore-manager reset-admin-password --password "${PULP_ADMIN_PASSWORD}"
fi
fi
set -x

Expand Down
2 changes: 1 addition & 1 deletion images/compose/compose.folders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
- "./assets/certs:/etc/pulp/certs:z"
- "../../pulp_storage:/var/lib/pulp:z"
environment:
PULP_ADMIN_PASSWORD: password
PULP_DEFAULT_ADMIN_PASSWORD: password

pulp_content:
image: "pulp/pulp-minimal:latest"
Expand Down
2 changes: 1 addition & 1 deletion images/compose/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
- "./assets/certs:/etc/pulp/certs:z"
- "pulp:/var/lib/pulp"
environment:
PULP_ADMIN_PASSWORD: password
PULP_DEFAULT_ADMIN_PASSWORD: password
restart: always

pulp_content:
Expand Down

0 comments on commit cf316c6

Please sign in to comment.