Commit initial

This commit is contained in:
Navas 2022-06-24 12:48:55 +02:00
commit b19ed9bbfc
5 changed files with 108 additions and 0 deletions

49
README.md Normal file
View file

@ -0,0 +1,49 @@
# Role : docker_healthchecks
## Services fournis
- main.yml : Installation de healthchecks sur un serveur docker_host
## Variables
Fournir les variables suivantes. Par exemple :
```yaml
docker_healthchecks_fqdn: healthchecks.local.lan
docker_healthchecks_version: v2.2.1
docker_healthchecks_data_dir: /data1
docker_healthchecks_service_id: healthchecks
docker_healthchecks_db: healthchecks
docker_healthchecks_db_user: healthchecks
docker_healthchecks_db_password: motdepassebdd
docker_healthchecks_config_env:
- DB=postgres
- DB_HOST=db
- DB_NAME={{ docker_healthchecks_db }}
- DB_USER={{ docker_healthchecks_db_user }}
- DB_PASSWORD={{ docker_healthchecks_db_password }}
- DB_PORT=5432
- etc
```
| Option | Valeur par défaut | Description |
|---------------------------------|-------------------|--------------------------------------------------------------------------------------------|
| docker_healthchecks_fqdn | | Le fqdn pour accéder à healthchecks |
| docker_healthchecks_version | | Version de l'image healthchecks |
| docker_healthchecks_data_dir | | L'emplacement dans lequel se trouvent les volumes de donnees docker pour le service |
| docker_healthchecks_service_id | | Le nom de service souhaité : conditionne le nommage des dossiers et le routage par traefik |
| docker_healthchecks_db | | Le nom de la base de données |
| docker_healthchecks_db_user | | Le nom du user propriétaire de la base de données |
| docker_healthchecks_db_password | | Le mot de passe du user propriétaire de la base de données |
| docker_healthchecks_config_env | | Une liste de variables d'environnement pour la configuration de healtchecks |
## Configuration de healthchecks
Une part de la configuration de healthchecks se fait dans les variables d'environnement qui lui sont fournies via docker_healthchecks_config_env
Après le premier démarrage il sera nécessaire de créer un admin, qui pourra poursuivre la configuration depuis l'interface web, avec :
```bash
docker-compose run healthchecks /opt/healthchecks/manage.py createsuperuser
```

0
defaults/main.yml Normal file
View file

5
handlers/main.yml Normal file
View file

@ -0,0 +1,5 @@
- name: docker-compose-up
shell: |
docker-compose up -d
args:
chdir: /opt/{{ docker_healthchecks_service_id }}/

14
tasks/main.yml Normal file
View file

@ -0,0 +1,14 @@
- name: docker directory
file:
path: /opt/{{ docker_healthchecks_service_id }}/
state: directory
- name: prepare docker-compose.yml
template:
src: "{{ item }}"
dest: /opt/{{ docker_healthchecks_service_id }}/
with_items:
- docker-compose.yml
notify: docker-compose-up

View file

@ -0,0 +1,40 @@
# {{ ansible_managed }}
version: '3.1'
services:
healthchecks:
image: healthchecks/healthchecks:{{ docker_healthchecks_version }}
environment: {{ docker_healthchecks_config_env }}
restart: always
networks:
- traefik
- healthchecks
labels:
- "org.label-schema.group=monitoring"
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.{{ docker_healthchecks_service_id }}.entrypoints=web"
- "traefik.http.routers.{{ docker_healthchecks_service_id }}.rule=Host(`{{ docker_healthchecks_fqdn }}`)"
- "traefik.http.services.{{ docker_healthchecks_service_id }}.loadbalancer.server.port=8000"
depends_on:
- db
command: bash -c 'uwsgi /opt/healthchecks/docker/uwsgi.ini'
db:
image: postgres:13
volumes:
- {{ docker_healthchecks_data_dir }}/{{ docker_healthchecks_service_id }}/postgresql-data:/var/lib/postgresql/data
environment:
POSTGRES_DB: "{{ docker_healthchecks_db }}"
POSTGRES_USER: "{{ docker_healthchecks_db_user }}"
POSTGRES_PASSWORD: "{{ docker_healthchecks_db_password }}"
networks:
- healthchecks
networks:
traefik:
external: true
healthchecks:
internal: true