feat: add blackbox monitoring and app3 deployment

- Add blackbox exporter role and playbooks
- Add cadvisor, docker, httpbin roles
- Add app3 deployment playbooks
- Configure blackbox monitoring
This commit is contained in:
Freazzzing
2026-02-04 10:20:24 +00:00
parent d70c2813de
commit aa3e0c8f54
19 changed files with 1045 additions and 0 deletions

View File

@ -0,0 +1,126 @@
---
# Blackbox Exporter configuration
blackbox_version: "latest"
blackbox_port: 8083
blackbox_image: "prom/blackbox-exporter:{{ blackbox_version }}"
blackbox_container_name: "blackbox-exporter"
# Все цели для мониторинга из ИП и твоего списка
blackbox_targets:
# Основные сервисы стенда (из ИП)
- name: "app1-nginx"
url: "http://192.168.0.110/"
module: "http_2xx"
- name: "app2-postgresql"
url: "http://192.168.0.111:9187/metrics" # postgres_exporter
module: "http_2xx"
- name: "app3-httpbin"
url: "http://192.168.0.112:8080/get"
module: "http_2xx"
- name: "app3-cadvisor"
url: "http://192.168.0.112:8081/metrics"
module: "http_2xx"
- name: "git-forgejo"
url: "http://192.168.0.100:3000/"
module: "http_2xx"
- name: "ansible"
url: "http://192.168.0.101:9100/metrics" # node_exporter
module: "http_2xx"
- name: "vault"
url: "http://192.168.0.103:8200/ui/"
module: "http_2xx"
- name: "victoriametrics"
url: "http://192.168.0.104:8428/metrics"
module: "http_2xx"
- name: "prometheus"
url: "http://192.168.0.105:9090/metrics"
module: "http_2xx"
- name: "grafana"
url: "http://192.168.0.106:3000"
module: "http_2xx"
# Домены из твоего списка
- name: "wiki-pvenode"
url: "http://wiki.pvenode.ru/"
module: "http_2xx"
- name: "victoria-pvenode"
url: "http://victoria.pvenode.ru/"
module: "http_2xx"
- name: "vault-pvenode"
url: "http://vault.pvenode.ru/"
module: "http_2xx"
- name: "tasks-pvenode"
url: "http://tasks.pvenode.ru/"
module: "http_2xx"
- name: "python-pvenode"
url: "http://python.pvenode.ru/"
module: "http_2xx"
- name: "pvenode-main"
url: "http://pvenode.ru/"
module: "http_2xx"
- name: "proxmox-pvenode"
url: "http://proxmox.pvenode.ru/"
module: "http_2xx"
- name: "prometheus-pvenode"
url: "http://prometheus.pvenode.ru/"
module: "http_2xx"
- name: "postgre-pvenode"
url: "http://postgre.pvenode.ru/"
module: "http_2xx"
- name: "ovpn-pvenode"
url: "http://ovpn.pvenode.ru/"
module: "http_2xx"
- name: "nginxpm-pvenode"
url: "http://nginxpm.pvenode.ru/"
module: "http_2xx"
- name: "nextcloud-pvenode"
url: "http://nextcloud.pvenode.ru/"
module: "http_2xx"
- name: "money-pvenode"
url: "http://money.pvenode.ru/"
module: "http_2xx"
- name: "grafana-pvenode"
url: "http://grafana.pvenode.ru/"
module: "http_2xx"
- name: "gitlab-pvenode"
url: "http://gitlab.pvenode.ru/"
module: "http_2xx"
- name: "forgejo-pvenode"
url: "http://forgejo.pvenode.ru/"
module: "http_2xx"
- name: "bitwarden-pvenode"
url: "http://bitwarden.pvenode.ru/"
module: "http_2xx"
- name: "app1-pvenode"
url: "http://app1.pvenode.ru/"
module: "http_2xx"
- name: "ansible-pvenode"
url: "http://ansimble.pvenode.ru/"
module: "http_2xx"

View File

@ -0,0 +1,42 @@
modules:
# HTTP проверка (2xx статус)
http_2xx:
prober: http
timeout: 10s
http:
valid_status_codes: [200, 301, 302, 403]
method: GET
preferred_ip_protocol: "ip4"
follow_redirects: true
fail_if_ssl: false
fail_if_not_ssl: false
tls_config:
insecure_skip_verify: true # для тестового стенда
# HTTP POST проверка
http_post_2xx:
prober: http
http:
method: POST
preferred_ip_protocol: "ip4"
# TCP подключение
tcp_connect:
prober: tcp
timeout: 5s
# SSL проверки (можно добавить позже)
ssl_check:
prober: http
http:
fail_if_not_ssl: true
tls_config:
insecure_skip_verify: false
preferred_ip_protocol: "ip4"
# ICMP (ping)
icmp_check:
prober: icmp
timeout: 5s
icmp:
preferred_ip_protocol: "ip4"

View File

@ -0,0 +1,58 @@
---
- name: Create directory for blackbox config
file:
path: /etc/blackbox_exporter
state: directory
mode: '0755'
tags: blackbox
- name: Copy blackbox configuration
copy:
src: files/blackbox.yml
dest: /etc/blackbox_exporter/config.yml
mode: '0644'
tags: blackbox
- name: Ensure blackbox-exporter container is running
community.docker.docker_container:
name: "{{ blackbox_container_name }}"
image: "{{ blackbox_image }}"
state: started
restart_policy: unless-stopped
ports:
- "{{ blackbox_port }}:9115"
volumes:
- "/etc/blackbox_exporter/config.yml:/etc/blackbox_exporter/config.yml"
command:
- "--config.file=/etc/blackbox_exporter/config.yml"
- "--web.listen-address=:9115"
tags: blackbox
- name: Configure UFW for blackbox-exporter
ufw:
rule: allow
port: "{{ blackbox_port }}"
proto: tcp
comment: "Blackbox Exporter"
tags: blackbox
- name: Wait for blackbox-exporter to be ready
wait_for:
port: "{{ blackbox_port }}"
host: "{{ ansible_host }}"
delay: 2
timeout: 60
tags: blackbox
- name: Test blackbox-exporter with local target
uri:
url: "http://{{ ansible_host }}:{{ blackbox_port }}/probe?target=http://192.168.0.112:8080/get&module=http_2xx"
return_content: true
status_code: 200
register: blackbox_test
tags: blackbox
- name: Show blackbox-exporter status
debug:
msg: "Blackbox Exporter deployed at http://{{ ansible_host }}:{{ blackbox_port }}/"
tags: blackbox