forked from ungleich-public/cdist-contrib
48 lines
1.6 KiB
Text
48 lines
1.6 KiB
Text
|
#!/bin/sh
|
||
|
|
||
|
os=$(cat "$__global/explorer/os")
|
||
|
|
||
|
case "$os" in
|
||
|
debian|ubuntu)
|
||
|
# Install netbox dependencies.
|
||
|
for pkg in python3-pip python3-venv python3-dev build-essential libxml2-dev \
|
||
|
libxslt1-dev libffi-dev libpq-dev libssl-dev zlib1g-dev curl virtualenv; do
|
||
|
__package $pkg
|
||
|
done
|
||
|
|
||
|
;;
|
||
|
*)
|
||
|
printf "Your operating system (%s) is currently not supported by this type (%s)\n" "$os" "${__type##*/}" >&2
|
||
|
printf "Please contribute an implementation for it if you can.\n" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
export DATABASE_NAME=$(cat "$__object/parameter/database")
|
||
|
export DATABASE_PASSWORD=$(cat "$__object/parameter/database-password")
|
||
|
export ALLOWED_HOST=$(cat "$__object/parameter/host")
|
||
|
export SECRET_KEY=$(cat "$__object/parameter/secret-key")
|
||
|
|
||
|
# Create system user used to run netbox.
|
||
|
__user netbox --system --home /opt/netbox --create-home
|
||
|
|
||
|
# Generate and upload netbox configuration.
|
||
|
mkdir -p "$__object/files"
|
||
|
"$__type/files/configuration.py.sh" > "$__object/files/configuration.py"
|
||
|
|
||
|
require="__user/netbox" __directory /opt/netbox/netbox/cdist --parents
|
||
|
require="__directory/opt/netbox/netbox/cdist " __file \
|
||
|
/opt/netbox/netbox/cdist/configuration.py --mode 640 --owner netbox \
|
||
|
--source "$__object/files/configuration.py"
|
||
|
|
||
|
# Upload systemd units and gunicorn configuration.
|
||
|
for unit in netbox netbox-rq; do
|
||
|
__file /etc/systemd/system/$unit.service \
|
||
|
--mode 644 --source "$__type/files/$unit.service" \
|
||
|
--onchange 'systemctl daemon-reload'
|
||
|
done
|
||
|
|
||
|
# Python worker configuration.
|
||
|
require="__user/netbox" __file /opt/netbox/gunicorn.py \
|
||
|
--mode 644 --source "$__type/files/gunicorn.py"
|