first commit
This commit is contained in:
35
files/entrypoint.sh-backup
Normal file
35
files/entrypoint.sh-backup
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR="/opt/containers/ansible-worker"
|
||||
DATA_DIR="${APP_DIR}/data"
|
||||
VENV_DIR="${DATA_DIR}/ansible_venv"
|
||||
COLL_BASE="${DATA_DIR}/collections"
|
||||
COLL_NETBOX_DIR="${COLL_BASE}/ansible_collections/netbox/netbox"
|
||||
|
||||
mkdir -p "$DATA_DIR"
|
||||
|
||||
# Bootstrap venv on first run
|
||||
if [ ! -x "${VENV_DIR}/bin/ansible" ]; then
|
||||
echo "[entrypoint] Creating venv in ${VENV_DIR} and installing packages..."
|
||||
python3 -m venv "${VENV_DIR}"
|
||||
"${VENV_DIR}/bin/python" -m pip install --upgrade pip setuptools wheel
|
||||
"${VENV_DIR}/bin/pip" install \
|
||||
"ansible-core==2.16.*" \
|
||||
"pytz" \
|
||||
"pynetbox==7.*"
|
||||
echo "[entrypoint] venv bootstrap complete."
|
||||
fi
|
||||
|
||||
# Ensure NetBox collection exists in the PERSISTENT collections path
|
||||
if [ ! -d "${COLL_NETBOX_DIR}" ]; then
|
||||
echo "[entrypoint] Installing netbox.netbox collection into ${COLL_BASE} ..."
|
||||
mkdir -p "${COLL_BASE}"
|
||||
"${VENV_DIR}/bin/ansible-galaxy" collection install netbox.netbox -p "${COLL_BASE}"
|
||||
echo "[entrypoint] netbox.netbox installed."
|
||||
fi
|
||||
|
||||
# Put venv first on PATH
|
||||
export PATH="${VENV_DIR}/bin:${PATH}"
|
||||
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user