ansible-debops-infrastructure

DebOps and Ansible scripts to manage my infrastructure
git clone git://git.erethon.com/ansible-debops-infrastructure
Log | Files | Refs

commit de61af8c5e47830beb46d1412f21e66de107e43f
parent f000e8abe46788303425197cf96b610fe8d7b6c2
Author: Dionysis Grigoropoulos <dgrig@erethon.com>
Date:   Sat, 25 Jan 2020 23:44:50 +0200

prometheus: Init role, add Grafana host variables

Diffstat:
ansible/inventory/host_vars/libreopsgrafana/prometheus.yml | 7+++++++
ansible/inventory/host_vars/productiongrafana/prometheus.yml | 7+++++++
ansible/roles/prometheus/handlers/main.yml | 6++++++
ansible/roles/prometheus/tasks/main.yml | 7+++++++
ansible/roles/prometheus/templates/prometheus.yml.j2 | 34++++++++++++++++++++++++++++++++++
5 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/ansible/inventory/host_vars/libreopsgrafana/prometheus.yml b/ansible/inventory/host_vars/libreopsgrafana/prometheus.yml @@ -0,0 +1,7 @@ +--- + +prometheus__node_targets: ['127.0.0.1'] +prometheus__http_targets: ['https://libreops.cc', 'https://pad.libreops.cc', + 'https://libredns.gr', 'https://libretooth.gr', 'https://librenet.gr', + 'https://gnu.gr', 'https://diskuti.gr', + 'https://doh.libredns.gr/dns-query?dns=lSIBAAABAAAAAAAACGxpYnJlZG5zAmdyAAABAAE'] diff --git a/ansible/inventory/host_vars/productiongrafana/prometheus.yml b/ansible/inventory/host_vars/productiongrafana/prometheus.yml @@ -0,0 +1,7 @@ +--- + +prometheus__node_targets: ['127.0.0.1', 'matrix.int.erethon.com', 'pgmatrix.int.erethon.com'] +prometheus__http_targets: ['https://erethon.com', + 'https://blog.erethon.com', 'https://grafana.erethon.com', + 'https://riot.dgrig.com', 'https://matrix.erethon.com', + 'https://plothopes.com', 'https://f.erethon.com'] diff --git a/ansible/roles/prometheus/handlers/main.yml b/ansible/roles/prometheus/handlers/main.yml @@ -0,0 +1,6 @@ +--- + +- name: 'Restart prometheus' + service: + name: prometheus + state: restarted diff --git a/ansible/roles/prometheus/tasks/main.yml b/ansible/roles/prometheus/tasks/main.yml @@ -0,0 +1,7 @@ +--- + +- name: 'Configure Prometheus' + template: + src: prometheus.yml.j2 + dest: /etc/prometheus/prometheus.yml + notify: Restart prometheus diff --git a/ansible/roles/prometheus/templates/prometheus.yml.j2 b/ansible/roles/prometheus/templates/prometheus.yml.j2 @@ -0,0 +1,34 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] + + - job_name: node + static_configs: + - targets: + {% for target in prometheus__node_targets %} + - '{{ target }}:9100' + {% endfor %} + +{% if prometheus__http_targets is defined %} + - job_name: 'blackbox' + metrics_path: /probe + params: + module: [http_2xx] + static_configs: + - targets: +{% for target in prometheus__http_targets %} + - {{ target }} +{% endfor %} + relabel_configs: + - source_labels: [__address__] + target_label: __param_target + - source_labels: [__param_target] + target_label: instance + - target_label: __address__ + replacement: 127.0.0.1:9115 +{% endif %}