Add new roles for monitoring

This commit is contained in:
2025-01-09 21:06:28 +01:00
parent 98ef8d9896
commit 067b325678
24 changed files with 1084 additions and 0 deletions

View File

@ -0,0 +1,5 @@
## Restart Blackbox-exporter on changes
- name: restart blackbox
ansible.builtin.service:
name: '{{ blackbox_service }}'
state: restarted

View File

@ -0,0 +1,25 @@
---
- name: Load variables
include_vars: "{{ ansible_os_family|lower }}.yml"
- name: Install Blackbox exporter
tags: blackbox-install
ansible.builtin.package:
name: '{{ blackbox_package }}'
state: latest
- name: Define Blackbox configuration
tags: blackbox-configure
ansible.builtin.template:
src: blackbox.config.j2
dest: '{{ blackbox_config }}'
backup: yes
notify: restart blackbox
- name: Enable Blackbox service
tags: blackbox-enable
ansible.builtin.service:
name: '{{ blackbox_service }}'
state: started
enabled: yes

View File

@ -0,0 +1,60 @@
{{ ansible_managed | comment }}
modules:
http_2xx:
prober: http
{% if inventory_hostname == 'check.home.arpa' %}
http:
preferred_ip_protocol: "ip4"
ip_protocol_fallback: true
{% endif %}
http_post_2xx:
prober: http
{% if inventory_hostname == 'check.home.arpa' %}
http:
method: POST
preferred_ip_protocol: "ip4"
ip_protocol_fallback: true
{% endif %}
tcp_connect:
prober: tcp
smtp_check:
prober: tcp
timeout: 5s
tcp:
{% if inventory_hostname == 'check.home.arpa' %}
preferred_ip_protocol: "ip4"
ip_protocol_fallback: true
{% endif %}
query_response:
- expect: "^220(.*)ESMTP(.*)$"
- send: "EHLO prober\r"
- expect: "^250-STARTTLS"
- send: "STARTTLS\r"
- expect: "^220"
- starttls: true
- send: "EHLO prober\r"
- expect: "^250-AUTH"
- send: "QUIT\r"
imap_check:
prober: tcp
timeout: 5s
tcp:
{% if inventory_hostname == 'check.home.arpa' %}
preferred_ip_protocol: "ip4"
ip_protocol_fallback: true
{% endif %}
query_response:
- expect: "OK.*STARTTLS"
- send: ". STARTTLS"
- expect: "OK"
- starttls: true
- send: ". capability"
- expect: "CAPABILITY IMAP4rev1"
icmp:
prober: icmp
{% if inventory_hostname == 'check.home.arpa' %}
icmp:
preferred_ip_protocol: "ip4"
ip_protocol_fallback: true
{% endif %}

View File

@ -0,0 +1,5 @@
---
# vars file for blackbox role
blackbox_package: prometheus-blackbox-exporter
blackbox_config: '/etc/prometheus/blackbox.yml'
blackbox_service: prometheus-blackbox-exporter

View File

@ -0,0 +1,5 @@
---
# vars file for blackbox role
blackbox_package: blackbox_exporter
blackbox_config: '/etc/blackbox_exporter/blackbox.yml'
blackbox_service: blackbox_exporter