From 6e9a478b70553e047fd3b8944b327ea973ee6ee7 Mon Sep 17 00:00:00 2001 From: findias Date: Wed, 6 May 2026 16:11:53 +0300 Subject: [PATCH] monitoring: derive nginx_exporter_listen from per-host wg_ip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default `nginx_exporter_listen: "10.10.0.2:9113"` hardcoded the first RU's WG address. With multiple RUs in groups['ru'] (live as of 2026-05-06), the second RU tried to bind 10.10.0.2:9113 — an address not assigned to its interface — and entered a systemd restart loop: HTTP server failed: listen tcp 10.10.0.2:9113: bind: cannot assign requested address vmagent's scrape_configs already uses `hostvars[h].wg_ip | default(wg_ru_ip)` per-host (vmagent-scrape.yml.j2), and node_exporter's listen address derives the same way. Bring nginx_exporter into line with that pattern so a fresh role apply on any RU produces a unit file that binds the local WG IP. Behaviour: * vm_my_ru (wg_ip=10.10.0.2) → listen 10.10.0.2:9113 (unchanged) * vm_my_ru2 (wg_ip=10.10.0.3) → listen 10.10.0.3:9113 (was broken) * future RUs auto-correct from inventory entry. Tested by re-deploying on vm_my_ru2: service active, port bound, metrics flow to vmagent → VictoriaMetrics. Grafana dashboards already group by instance label so multi-RU panels populate automatically. Signed-off-by: findias --- roles/monitoring/defaults/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/monitoring/defaults/main.yml b/roles/monitoring/defaults/main.yml index 34d12cd..5aa3c1b 100644 --- a/roles/monitoring/defaults/main.yml +++ b/roles/monitoring/defaults/main.yml @@ -69,8 +69,10 @@ node_exporter_service_name: "node_exporter" # nginx-prometheus-exporter (RU only — reads nginx stub_status, exports request # count, accepts, connections by state; scraped by EU vmagent over WireGuard). +# Listen on per-host WG IP so multi-RU works. Falls back to global wg_ru_ip +# (10.10.0.2) for hosts without an explicit wg_ip — matches scrape.yml.j2 logic. nginx_exporter_version: "latest" -nginx_exporter_listen: "10.10.0.2:9113" # RU WG interface +nginx_exporter_listen: "{{ hostvars[inventory_hostname].wg_ip | default(wg_ru_ip) }}:9113" nginx_exporter_bin_dir: "/usr/local/bin" nginx_stub_status_port: 8081 # localhost-only nginx server block