Commit initial

This commit is contained in:
Navas 2022-06-18 18:45:52 +02:00
commit d631695fca
5 changed files with 88 additions and 0 deletions

31
README.md Normal file
View file

@ -0,0 +1,31 @@
# Role : docker_prometheus
## Services fournis
- main.yml : Installation de prometheus sur un serveur docker_host
## Variables
Fournir les variables suivantes. Par exemple :
```yaml
docker_prometheus_fqdn: prometheus.local.lan
docker_prometheus_version: v0.23.0
docker_prometheus_data_dir: /data1
docker_prometheus_service_id: prometheus
docker_prometheus_retention_time: 90d
```
| Option | Valeur par défaut | Description |
|----------------------------------|-------------------|--------------------------------------------------------------------------------------------|
| docker_prometheus_fqdn | | Le fqdn pour accéder à prometheus |
| docker_prometheus_version | | Version de l'image prometheus |
| docker_prometheus_data_dir | | L'emplacement dans lequel se trouvent les volumes de donnees docker pour le service |
| docker_prometheus_service_id | | Le nom de service souhaité : conditionne le nommage des dossiers et le routage par traefik |
| docker_prometheus_retention_time | | La durée de rétention des données dans prometheus |
## Configuration de prometheus
Créer ou modifier le fichier de configuration principal prometheus.yml dans le dossier de configuration à côté du docker-compose et redémarrer le conteneur.

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_prometheus_service_id }}/

19
tasks/main.yml Normal file
View file

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

View file

@ -0,0 +1,33 @@
# {{ ansible_managed }}
version: '3.1'
services:
prometheus:
image: prom/prometheus:{{ docker_prometheus_version }}
environment:
- TZ=Europe/Paris
volumes:
- ./prometheus:/etc/prometheus
- {{ docker_prometheus_data_dir }}/{{ docker_prometheus_service_id }}/prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time={{ docker_prometheus_retention_time }}'
- '--web.enable-lifecycle'
restart: always
networks:
- traefik
labels:
- "org.label-schema.group=monitoring"
- "traefik.enable=true"
- "traefik.docker.network=traefik"
- "traefik.http.routers.{{ docker_prometheus_service_id }}.entrypoints=web"
- "traefik.http.routers.{{ docker_prometheus_service_id }}.rule=Host(`{{ docker_prometheus_fqdn }}`)"
- "traefik.http.services.{{ docker_prometheus_service_id }}.loadbalancer.server.port=9090"
networks:
traefik:
external: true