Add new roles for monitoring
This commit is contained in:
5
ansible/roles/blackbox-exporter/handlers/main.yml
Normal file
5
ansible/roles/blackbox-exporter/handlers/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
## Restart Blackbox-exporter on changes
|
||||
- name: restart blackbox
|
||||
ansible.builtin.service:
|
||||
name: '{{ blackbox_service }}'
|
||||
state: restarted
|
25
ansible/roles/blackbox-exporter/tasks/main.yml
Normal file
25
ansible/roles/blackbox-exporter/tasks/main.yml
Normal 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
|
60
ansible/roles/blackbox-exporter/templates/blackbox.config.j2
Normal file
60
ansible/roles/blackbox-exporter/templates/blackbox.config.j2
Normal 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 %}
|
5
ansible/roles/blackbox-exporter/vars/debian.yml
Normal file
5
ansible/roles/blackbox-exporter/vars/debian.yml
Normal 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
|
5
ansible/roles/blackbox-exporter/vars/openbsd.yml
Normal file
5
ansible/roles/blackbox-exporter/vars/openbsd.yml
Normal 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
|
Reference in New Issue
Block a user