From 0b9b2a90d1768dee9bb9f8dc07eb4f15b9a64a23 Mon Sep 17 00:00:00 2001 From: Erik Stambaugh Date: Mon, 3 Jan 2022 08:08:38 -0800 Subject: [PATCH] Add prometheus monitoring --- nextcloud.tf | 9 ++++++-- .../files/docker-compose.yaml | 23 +++++++++++++++++++ roles/monitoring-client/tasks/main.yaml | 19 +++++++++++++++ site.yaml | 1 + 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 roles/monitoring-client/files/docker-compose.yaml create mode 100644 roles/monitoring-client/tasks/main.yaml diff --git a/nextcloud.tf b/nextcloud.tf index e97fa76..7885959 100644 --- a/nextcloud.tf +++ b/nextcloud.tf @@ -88,12 +88,17 @@ module "nextcloud_sg" { { rule = "http-80-tcp" cidr_blocks = "0.0.0.0/0" -# cidr_blocks = "${chomp(data.http.myip.body)}/32" }, { rule = "https-443-tcp" cidr_blocks = "0.0.0.0/0" -# cidr_blocks = "${chomp(data.http.myip.body)}/32" + }, + { + from_port = 9100 + to_port = 9100 + protocol = "tcp" + description = "Prometheus node-exporter" + cidr_blocks = "${chomp(data.http.myip.body)}/32" }, ] } diff --git a/roles/monitoring-client/files/docker-compose.yaml b/roles/monitoring-client/files/docker-compose.yaml new file mode 100644 index 0000000..169c877 --- /dev/null +++ b/roles/monitoring-client/files/docker-compose.yaml @@ -0,0 +1,23 @@ +--- +version: "2" + +services: + + prometheus-node-exporter: + image: prom/node-exporter:latest + container_name: prometheus-node-exporter + restart: unless-stopped + 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)($$|/)' + expose: + - 9100 + ports: + - "9100:9100" + diff --git a/roles/monitoring-client/tasks/main.yaml b/roles/monitoring-client/tasks/main.yaml new file mode 100644 index 0000000..9bf1749 --- /dev/null +++ b/roles/monitoring-client/tasks/main.yaml @@ -0,0 +1,19 @@ +--- + +- name: create paths + file: + path: /srv/monitoring-client + state: directory + recurse: true + +- name: monitoring docker-compose + copy: + src: files/docker-compose.yaml + dest: /srv/monitoring-client/docker-compose.yaml + register: nginxconf + +- name: launch monitoring client + command: docker-compose up -d + args: + chdir: /srv/monitoring-client + diff --git a/site.yaml b/site.yaml index b9944bb..d973ed3 100644 --- a/site.yaml +++ b/site.yaml @@ -12,5 +12,6 @@ hosts: nextcloud roles: - { role: docker, become: yes } + - { role: monitoring-client, become: yes } - { role: nextcloud, become: yes }