From 270186dc118b4fa79239f7327aca618649c3b28f Mon Sep 17 00:00:00 2001 From: Olivier Navas Date: Sun, 12 Jun 2022 23:07:59 +0200 Subject: [PATCH] Commit initial --- README.md | 25 +++++++++++++++++++++++++ defaults/main.yml | 1 + handlers/main.yml | 5 +++++ tasks/main.yml | 14 ++++++++++++++ templates/docker-compose.yml | 24 ++++++++++++++++++++++++ 5 files changed, 69 insertions(+) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 tasks/main.yml create mode 100644 templates/docker-compose.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..df7498c --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# Role : docker_nodeexporter + +## Services fournis + +- main.yml : Installation de nodeexporter sur un serveur docker_host + + +## Variables + +Fournir les variables suivantes. Par exemple : + +```yaml +docker_nodeexporter_version: v1.3.1 +docker_nodeexporter_data_dir: /data1 +docker_nodeexporter_service_id: node-exporter +``` + +| Option | Valeur par défaut | Description | +|--------------------------------|-------------------|------------------------------------------------------------------| +| docker_nodeexporter_version | | Version de l'image nodeexporter | +| docker_nodeexporter_data_dir | | L'emplacement dans lequel se trouvent le dossier docker | +| docker_nodeexporter_service_id | | Le nom de service souhaité : conditionne le nommage des dossiers | +| docker_nodeexporter_port | 9100 | Le numero de port local pour l'accès à nodeexporter | + + diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..dced93b --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1 @@ +docker_nodeexporter_port: "9100" diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..093b13a --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,5 @@ +- name: docker-compose-up + shell: | + docker-compose up -d + args: + chdir: /opt/{{ docker_nodeexporter_service_id }}/ diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..504918a --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,14 @@ +- name: docker directory + file: + path: /opt/{{ docker_nodeexporter_service_id }}/ + state: directory + +- name: prepare docker-compose.yml + template: + src: "{{ item }}" + dest: /opt/{{ docker_nodeexporter_service_id }}/ + with_items: + - docker-compose.yml + notify: docker-compose-up + + diff --git a/templates/docker-compose.yml b/templates/docker-compose.yml new file mode 100644 index 0000000..1178bb7 --- /dev/null +++ b/templates/docker-compose.yml @@ -0,0 +1,24 @@ +# {{ ansible_managed }} +version: '3.1' + +services: + nodeexporter: + image: prom/node-exporter:{{ docker_nodeexporter_version }} + environment: + - TZ=Europe/Paris + volumes: + - /proc:/host/proc:ro + - /sys:/host/sys:ro + - /:/rootfs:ro + command: + - '--path.procfs=/host/proc' + - '--path.rootfs=/rootfs' + - '--path.sysfs=/host/sys' + - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)' + restart: always + labels: + org.label-schema.group: "monitoring" + ports: + - {{ docker_nodeexporter_port }}:9100 + +