update
This commit is contained in:
parent
7a64cfdf66
commit
efd30e9a28
12
Dockerfile
12
Dockerfile
@ -1,5 +1,5 @@
|
|||||||
### DEV ENV ###
|
### DEV ENV ###
|
||||||
FROM python:3.9.16-slim-bullseye AS app_dev
|
FROM python:3.13.1-slim-bookworm AS app_dev
|
||||||
|
|
||||||
ARG APP_UID=1000
|
ARG APP_UID=1000
|
||||||
ARG APP_GID=1000
|
ARG APP_GID=1000
|
||||||
@ -9,20 +9,20 @@ ENV PYTHONUNBUFFERED 1
|
|||||||
|
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
|
||||||
RUN apt update && apt install -y procps less netcat libmariadb-dev-compat libmariadb-dev mariadb-client gcc nginx-light
|
RUN apt update && apt install -y procps less netcat-traditional libmariadb-dev-compat libmariadb-dev mariadb-client gcc nginx-light pkg-config
|
||||||
|
|
||||||
COPY ./docker/nginx/dev.conf /etc/nginx/sites-enabled/updatesdashboard.conf
|
COPY ./docker/nginx/updatesdashboard.conf /etc/nginx/sites-enabled/updatesdashboard.conf
|
||||||
RUN rm -f /etc/nginx/sites-enabled/default
|
RUN rm -f /etc/nginx/sites-enabled/default
|
||||||
|
|
||||||
COPY ./docker/scripts/entrypoint.dev.sh /usr/local/bin/entrypoint
|
|
||||||
RUN chmod +x /usr/local/bin/entrypoint
|
|
||||||
|
|
||||||
RUN addgroup --system gunicorn --gid ${APP_GID} && adduser --uid ${APP_UID} --system --disabled-login --group gunicorn
|
RUN addgroup --system gunicorn --gid ${APP_GID} && adduser --uid ${APP_UID} --system --disabled-login --group gunicorn
|
||||||
|
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip
|
||||||
COPY ./app/requirements.txt .
|
COPY ./app/requirements.txt .
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
|
COPY ./docker/scripts/entrypoint.dev.sh /usr/local/bin/entrypoint
|
||||||
|
RUN chmod +x /usr/local/bin/entrypoint
|
||||||
|
|
||||||
COPY ./app/ .
|
COPY ./app/ .
|
||||||
COPY ./app/updatesdashboard/.env.dev ./updatesdashboard/.env
|
COPY ./app/updatesdashboard/.env.dev ./updatesdashboard/.env
|
||||||
|
|
||||||
|
|||||||
72
README.md
72
README.md
@ -1,72 +0,0 @@
|
|||||||
# Updates Dashboard
|
|
||||||
|
|
||||||
## Summary
|
|
||||||
|
|
||||||
This is a tool to have a clear view of the which servers are outdated, and keep trace of the updates.
|
|
||||||
|
|
||||||
## Technical information
|
|
||||||
|
|
||||||
It runs with Django. The information are daily generated by an ansible playbook, which is not located in this repo (infrastructure/updates-dashboard-ansible).
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
### Run with docker
|
|
||||||
|
|
||||||
```
|
|
||||||
docker-compose up
|
|
||||||
```
|
|
||||||
|
|
||||||
### On-premise
|
|
||||||
|
|
||||||
Dependencies in case of Debian 10.
|
|
||||||
```
|
|
||||||
apt install python3-venv libmariadb-dev-compat libmariadb-dev mariadb-client python3-dev gcc
|
|
||||||
```
|
|
||||||
Following procedure to install the apps.
|
|
||||||
```
|
|
||||||
useradd -d /var/www/updates-dashboard/ -g www-data -M -s /bin/false www-updash
|
|
||||||
cd /var/www/
|
|
||||||
git clone <URL> updates-dashboard
|
|
||||||
chown -R www-updash:www-data updates-dashboard
|
|
||||||
touch /var/log/gunicorn.log
|
|
||||||
chown www-updash:www-data /var/log/gunicorn.log
|
|
||||||
cd updates-dashboard
|
|
||||||
python3 -m venv updash-venv
|
|
||||||
source updash-venv/bin/activate
|
|
||||||
(updash-venv) pip install -r requirements.txt
|
|
||||||
mkdir results results-packages
|
|
||||||
cp defaults/settings_local.py updatesdashboard/
|
|
||||||
cp defaults/gunicorn.service /etc/systemd/system/
|
|
||||||
cp defaults/updates-dashboard.conf /etc/nginx/sites-available
|
|
||||||
cd /etc/nginx/sites-enabled
|
|
||||||
ln -s /etc/nginx/sites-avaiable/updates-dashboard.conf .
|
|
||||||
```
|
|
||||||
* Set `settings_local.py` with correct values
|
|
||||||
* Set `gunicorn.service` with correct values
|
|
||||||
* Set `updates-dashboard.conf` with correct values
|
|
||||||
```shell
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable gunicorn.service
|
|
||||||
nginx -t
|
|
||||||
systemctl reload nginx
|
|
||||||
```
|
|
||||||
To initialize the project:
|
|
||||||
```shell
|
|
||||||
(updash-venv) ./manage.py makemigrations
|
|
||||||
(updash-venv) ./manage.py makemigrations dashboard
|
|
||||||
(updash-venv) ./manage.py collectstatic
|
|
||||||
(updash-venv) ./manage.py migrate
|
|
||||||
(updash-venv) ./manage.py loaddata dashboard/fixtures/os.yaml
|
|
||||||
(updash-venv) ./manage.py loaddata dashboard/fixtures/teams.yaml
|
|
||||||
```
|
|
||||||
Vérifier les flux de mise à jour des données. Ansible->Dashboard
|
|
||||||
Vérifier le sql mode de la base de données
|
|
||||||
```shell
|
|
||||||
set @@global.sql_mode='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
|
|
||||||
```
|
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
* playbook to install via ansible ?
|
|
||||||
* playbook to update via ansible ?
|
|
||||||
* buttons should be 'previous / next results' instead of 'previous / next day'
|
|
||||||
@ -72,6 +72,13 @@
|
|||||||
version: '11',
|
version: '11',
|
||||||
end_of_support: 2026-06-30
|
end_of_support: 2026-06-30
|
||||||
}
|
}
|
||||||
|
- model: dashboard.os
|
||||||
|
pk: null
|
||||||
|
fields: {
|
||||||
|
distribution: Debian,
|
||||||
|
version: '12',
|
||||||
|
end_of_support: 2028-06-30
|
||||||
|
}
|
||||||
|
|
||||||
# Ubuntu Server
|
# Ubuntu Server
|
||||||
- model: dashboard.os
|
- model: dashboard.os
|
||||||
@ -207,6 +214,13 @@
|
|||||||
version: '22.04',
|
version: '22.04',
|
||||||
end_of_support: 2027-04-01
|
end_of_support: 2027-04-01
|
||||||
}
|
}
|
||||||
|
- model: dashboard.os
|
||||||
|
pk: null
|
||||||
|
fields: {
|
||||||
|
distribution: Ubuntu,
|
||||||
|
version: '24.04',
|
||||||
|
end_of_support: 2029-04-01
|
||||||
|
}
|
||||||
|
|
||||||
# CentOS
|
# CentOS
|
||||||
- model: dashboard.os
|
- model: dashboard.os
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a class="navbar-brand" href="{% url 'index' %}">Updates Dashboard</a>
|
<a class="navbar-brand" href="{% url 'index' %}">Hyrule - Servers information</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav navbar-right top-nav">
|
<div class="nav navbar-right top-nav">
|
||||||
<!-- <button class="btn btn-lg btn-danger disabled">Confidential information</button> -->
|
<!-- <button class="btn btn-lg btn-danger disabled">Confidential information</button> -->
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a class="navbar-brand" href="{% url 'index' %}">Updates Dashboard</a>
|
<a class="navbar-brand" href="{% url 'index' %}">Hyrule - Servers Informations</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="nav navbar-right top-nav">
|
<div class="nav navbar-right top-nav">
|
||||||
<!-- <button class="btn btn-lg btn-danger disabled">Confidential information</button> -->
|
<!-- <button class="btn btn-lg btn-danger disabled">Confidential information</button> -->
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# home
|
# home
|
||||||
re_path(r'^/?$',
|
re_path(r'^$',
|
||||||
views.index,
|
views.index,
|
||||||
name='index'),
|
name='index'),
|
||||||
|
|
||||||
|
|||||||
@ -5,4 +5,5 @@ server4;Debian;11;0;147
|
|||||||
server5;Ubuntu;20.04;0;308
|
server5;Ubuntu;20.04;0;308
|
||||||
server6;Ubuntu;22.04;0;147
|
server6;Ubuntu;22.04;0;147
|
||||||
server7;OpenBSD;6.4;3;119
|
server7;OpenBSD;6.4;3;119
|
||||||
server8;Ubuntu;20.04;0;28
|
server8;Ubuntu;18.04;0;28
|
||||||
|
server9;Debian;12;0;147
|
||||||
|
|||||||
|
@ -1,9 +1,9 @@
|
|||||||
GUNICORN_CMD_ARGS=--bind=127.0.0.1:3000 --workers=3 --timeout=300 --error-logfile=/var/log/gunicorn-error.log
|
GUNICORN_CMD_ARGS=--bind=127.0.0.1:3001 --workers=3 --timeout=300 --error-logfile=/var/log/gunicorn-error.log
|
||||||
DJANGO_SUPERUSER_PASSWORD=admin
|
DJANGO_SUPERUSER_PASSWORD=admin
|
||||||
SECRET_KEY=uv88xpv8kb2r6j7rubtnhkps
|
SECRET_KEY=uv88xpv8kb2r6j7rubtnhkps
|
||||||
DATABASE_NAME=updates_dashboard
|
DATABASE_NAME=infra_dashboard
|
||||||
DATABASE_USER=updates_dashboard
|
DATABASE_USER=infra_dashboard
|
||||||
DATABASE_PASSWORD=miengetBatheajOf
|
DATABASE_PASSWORD=sebisdown
|
||||||
DATABASE_HOST=mysql
|
DATABASE_HOST=mysql
|
||||||
DATABASE_PORT=3306
|
DATABASE_PORT=3306
|
||||||
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
|
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1
|
||||||
|
|||||||
@ -110,13 +110,10 @@ DEBUG_TOOLBAR = True
|
|||||||
|
|
||||||
# Internationalization
|
# Internationalization
|
||||||
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
USE_I18N = True
|
USE_I18N = True
|
||||||
|
|
||||||
USE_L10N = True
|
USE_L10N = True
|
||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
version: '0.1'
|
|
||||||
services:
|
services:
|
||||||
web:
|
web:
|
||||||
container_name: updatesdashboard.front
|
container_name: updatesdashboard.front
|
||||||
@ -6,28 +5,15 @@ services:
|
|||||||
context: ./
|
context: ./
|
||||||
target: app_dev
|
target: app_dev
|
||||||
ports:
|
ports:
|
||||||
- "3000:3001"
|
- "3000:3000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./app/:/app/
|
- ./app/:/app/
|
||||||
env_file:
|
env_file:
|
||||||
- ./app/updatesdashboard/.env.dev
|
- ./app/updatesdashboard/.env.dev
|
||||||
networks:
|
networks:
|
||||||
- updates-dashboard-network
|
- infra-dashboard
|
||||||
depends_on:
|
|
||||||
- mysql
|
|
||||||
mysql:
|
|
||||||
image: mysql:8.0
|
|
||||||
container_name: updatesdashboard.mysql
|
|
||||||
environment:
|
|
||||||
MYSQL_ROOT_PASSWORD: root
|
|
||||||
MYSQL_DATABASE: updates_dashboard
|
|
||||||
MYSQL_USER: updates_dashboard
|
|
||||||
MYSQL_PASSWORD: miengetBatheajOf
|
|
||||||
ports:
|
|
||||||
- "3306:3306"
|
|
||||||
networks:
|
|
||||||
- updates-dashboard-network
|
|
||||||
networks:
|
|
||||||
updates-dashboard-network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
|
networks:
|
||||||
|
infra-dashboard:
|
||||||
|
name: infra-dashboard_infra-dashboard
|
||||||
|
external: true
|
||||||
|
|||||||
25
docker/nginx/updatesdashboard.conf
Normal file
25
docker/nginx/updatesdashboard.conf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
server {
|
||||||
|
listen 3000;
|
||||||
|
server_name updates-dashboard.hyrule.ovh;
|
||||||
|
|
||||||
|
# css, js…
|
||||||
|
location /static {
|
||||||
|
alias /app/static;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request_uri !~ "^/admin.*") {
|
||||||
|
# don't rewrite admin
|
||||||
|
rewrite ^/(.*)/$ /$1 permanent;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
include proxy_params;
|
||||||
|
proxy_pass http://127.0.0.1:3001;
|
||||||
|
proxy_connect_timeout 120s;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log /var/log/updatesdashboard-error.log;
|
||||||
|
access_log /var/log/updatesdashboard-access.log;
|
||||||
|
}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
until nc -vz $1 $2; do echo "Waiting for MySQL $1:$2..."; sleep 3; done;
|
until nc -vz $1 $2; do echo "Waiting for MySQL $1:$2..."; sleep 3; done;
|
||||||
|
|
||||||
python /app/manage.py migrate
|
python /app/manage.py migrate
|
||||||
python /app/manage.py collectstatic
|
python /app/manage.py collectstatic --clear --no-input
|
||||||
python /app/manage.py loaddata /app/dashboard/fixtures/os.yaml
|
python /app/manage.py loaddata /app/dashboard/fixtures/os.yaml
|
||||||
python /app/manage.py createsuperuser --noinput --username admin --email test@example.com
|
python /app/manage.py createsuperuser --noinput --username admin --email test@example.com
|
||||||
service nginx start
|
service nginx start
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
until nc -vz $1 $2; do echo "Waiting for MySQL $1:$2..."; sleep 3; done;
|
until nc -vz $1 $2; do echo "Waiting for MySQL $1:$2..."; sleep 3; done;
|
||||||
|
|
||||||
#python /app/manage.py flush --no-input
|
python /app/manage.py migrate
|
||||||
#python /app/manage.py migrate
|
python /app/manage.py collectstatic
|
||||||
#python /app/manage.py loaddata dashboard/fixtures/os.yaml
|
python /app/manage.py loaddata /app/dashboard/fixtures/os.yaml
|
||||||
|
python /app/manage.py createsuperuser --noinput --username admin --email test@example.com
|
||||||
|
service nginx start
|
||||||
|
gunicorn updatesdashboard.wsgi:application
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user