Compare commits

..

3 Commits

Author SHA1 Message Date
efd30e9a28 update 2025-01-14 11:51:45 +01:00
7a64cfdf66 Cleaning Infolegale from sources and test results file 2023-04-06 11:16:23 +02:00
7c6114ec3c Merge pull request 'Dockerization' (#1) from dockerisation into main
Reviewed-on: #1
2023-04-05 11:42:19 +02:00
14 changed files with 78 additions and 135 deletions

View File

@ -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/updatesdashboard.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

View File

@ -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 git@gitlab.infolegale.net:infrastructure/updates-dashboard.git 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'

View File

@ -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

View File

@ -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' %}">Infolegale - Servers information</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&#45;lg btn&#45;danger disabled">Confidential information</button> --> <!-- <button class="btn btn&#45;lg btn&#45;danger disabled">Confidential information</button> -->

View File

@ -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' %}">Infolegale - Servers Informations</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&#45;lg btn&#45;danger disabled">Confidential information</button> --> <!-- <button class="btn btn&#45;lg btn&#45;danger disabled">Confidential information</button> -->

View File

@ -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'),

View File

@ -1,19 +1,9 @@
vlearning-db001-tst.infolegale.net;Debian;10;0;5 server1;Debian;8;0;5
app-db001-tst.infolegale.net;Debian;10;0;9 server2;Debian;9;0;9
consults-db001-tst.infolegale.net;Debian;10;0;147 server3;Debian;10;0;147
vador-db001-tst.infolegale.net;Debian;10;0;147 server4;Debian;11;0;147
tlearning-db003-tst.infolegale.net;Ubuntu;18.04;0;308 server5;Ubuntu;20.04;0;308
transdb-db001-tst.infolegale.net;Debian;10;0;147 server6;Ubuntu;22.04;0;147
mysql8-db001-tst.infolegale.net;Debian;11;3;119 server7;OpenBSD;6.4;3;119
mongo-db001-tst.infolegale.net;Ubuntu;20.04;0;28 server8;Ubuntu;18.04;0;28
orchestrator-mgr001-tst.infolegale.net;Ubuntu;20.04;0;28 server9;Debian;12;0;147
redis5-db001-tst.infolegale.net;Debian;10;0;326
redis-db001-tst.infolegale.net;Ubuntu;18.04;0;326
docker-hpv001-tst.infolegale.net;Ubuntu;20.04;0;106
docker-hpv002-tst.infolegale.net;Ubuntu;20.04;0;398
docker-hpv003-tst.infolegale.net;Ubuntu;20.04;0;125
rundeck-sch001-tst.infolegale.net;Debian;10;0;91
proxysql-db001-tst.infolegale.net;Ubuntu;20.04;0;475
docker-hpv005-tst.infolegale.net;Ubuntu;20.04;0;119
docker-hpv004-tst.infolegale.net;Ubuntu;20.04;0;28
docker-hpv006-tst.infolegale.net;Ubuntu;20.04;0;309

1 vlearning-db001-tst.infolegale.net server1 Debian 10 8 0 5
2 app-db001-tst.infolegale.net server2 Debian 10 9 0 9
3 consults-db001-tst.infolegale.net server3 Debian 10 10 0 147
4 vador-db001-tst.infolegale.net server4 Debian 10 11 0 147
5 tlearning-db003-tst.infolegale.net server5 Ubuntu 18.04 20.04 0 308
6 transdb-db001-tst.infolegale.net server6 Debian Ubuntu 10 22.04 0 147
7 mysql8-db001-tst.infolegale.net server7 Debian OpenBSD 11 6.4 3 119
8 mongo-db001-tst.infolegale.net server8 Ubuntu 20.04 18.04 0 28
9 orchestrator-mgr001-tst.infolegale.net server9 Ubuntu Debian 20.04 12 0 28 147
redis5-db001-tst.infolegale.net Debian 10 0 326
redis-db001-tst.infolegale.net Ubuntu 18.04 0 326
docker-hpv001-tst.infolegale.net Ubuntu 20.04 0 106
docker-hpv002-tst.infolegale.net Ubuntu 20.04 0 398
docker-hpv003-tst.infolegale.net Ubuntu 20.04 0 125
rundeck-sch001-tst.infolegale.net Debian 10 0 91
proxysql-db001-tst.infolegale.net Ubuntu 20.04 0 475
docker-hpv005-tst.infolegale.net Ubuntu 20.04 0 119
docker-hpv004-tst.infolegale.net Ubuntu 20.04 0 28
docker-hpv006-tst.infolegale.net Ubuntu 20.04 0 309

View File

@ -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

View File

@ -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'

View File

@ -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/dev.conf Normal file
View File

@ -0,0 +1,25 @@
server {
listen 3001;
server_name localhost;
# 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:3000;
proxy_connect_timeout 120s;
proxy_read_timeout 300s;
}
error_log /var/log/updatesdashboard-error.log;
access_log /var/log/updatesdashboard-access.log;
}

View File

@ -1,6 +1,6 @@
server { server {
listen 3001; listen 3000;
server_name updates-dashboard.infolegale.net; server_name updates-dashboard.hyrule.ovh;
# css, js… # css, js…
location /static { location /static {
@ -14,7 +14,7 @@ server {
location / { location / {
include proxy_params; include proxy_params;
proxy_pass http://127.0.0.1:3000; proxy_pass http://127.0.0.1:3001;
proxy_connect_timeout 120s; proxy_connect_timeout 120s;
proxy_read_timeout 300s; proxy_read_timeout 300s;

View File

@ -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

View File

@ -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 "$@"