Skip to content

Commit

Permalink
Merge pull request #543 from mdellweg/417_default_admin_password
Browse files Browse the repository at this point in the history
default admin password
  • Loading branch information
dkliban committed Sep 19, 2023
2 parents 49be51b + 5b28f4b commit d42d7a6
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 44 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.
4 changes: 0 additions & 4 deletions images/Containerfile.core.base
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,11 @@ COPY images/assets/readyz.py /usr/bin/readyz.py
COPY images/assets/route_paths.py /usr/bin/route_paths.py
COPY images/assets/wait_on_postgres.py /usr/bin/wait_on_postgres.py
COPY images/assets/wait_on_database_migrations.sh /usr/bin/wait_on_database_migrations.sh
COPY images/assets/pulp-common-entrypoint.sh /pulp-common-entrypoint.sh
COPY images/assets/pulp-api /usr/bin/pulp-api
COPY images/assets/pulp-content /usr/bin/pulp-content
COPY images/assets/pulp-resource-manager /usr/bin/pulp-resource-manager
COPY images/assets/pulp-worker /usr/bin/pulp-worker

# Need to precreate when running pulp as the pulp user
RUN touch /var/log/galaxy_api_access.log && \
chown pulp:pulp /var/log/galaxy_api_access.log && \
chmod u+rw /var/log/galaxy_api_access.log

ENTRYPOINT ["/pulp-common-entrypoint.sh"]
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
14 changes: 0 additions & 14 deletions images/assets/pulp-common-entrypoint.sh

This file was deleted.

14 changes: 0 additions & 14 deletions images/assets/pulp-resource-manager

This file was deleted.

1 change: 0 additions & 1 deletion images/assets/pulp-worker
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
/usr/bin/wait_on_postgres.py
/usr/bin/wait_on_database_migrations.sh

export PULP_SETTINGS=/etc/pulp/settings.py
export PATH=/usr/local/bin:/usr/bin/
exec pulpcore-worker
2 changes: 1 addition & 1 deletion images/assets/readyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def is_content_healthy(path):
The cmdline value for this PID looks like:
```
# pip installation
gunicorn: master \[pulp-{content,api,worker,resource-manager}\]
gunicorn: master \[pulp-{content,api}\]
```
OR
```
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
4 changes: 4 additions & 0 deletions images/pulp-minimal/stable/Containerfile.core
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ RUN pip3 install --upgrade \
pulp-ostree${PULP_OSTREE_VERSION} && \
rm -rf /root/.cache/pip

# Prevent pip-installed /usr/local/bin/pulp-content from getting run instead of
# our /usr/bin/pulp-content script.
RUN rm -r /usr/local/bin/pulp-content

USER pulp:pulp
RUN PULP_STATIC_ROOT=/var/lib/operator/static/ PULP_CONTENT_ORIGIN=localhost \
/usr/local/bin/pulpcore-manager collectstatic --clear --noinput --link
Expand Down

0 comments on commit d42d7a6

Please sign in to comment.