Capture current Ansible control plane state

Commit the accumulated infrastructure work that was living only in the
working tree: monitoring stack, emergency access/bot, gyro allocator,
grimmory, adguard, backup audit and the OpenCode agent definitions.

Also ignore Python bytecode, local archives and Nix/direnv artifacts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTocXkGUUazHdKKd3r9k71
This commit is contained in:
Dmitry
2026-08-26 21:39:28 +03:00
co-authored by Claude Opus 5
parent 4bafa7d09e
commit c676be81ec
126 changed files with 10583 additions and 44 deletions
@@ -0,0 +1,30 @@
#!/bin/sh
# Managed by Ansible. Export SMART health to Node Exporter's textfile collector.
set -eu
METRICS_DIR="{{ monitoring_exporter_textfile_dir }}"
METRICS_FILE="$METRICS_DIR/homelab_smartctl.prom"
METRICS_TMP=$(mktemp "$METRICS_FILE.XXXXXX")
trap 'rm -f "$METRICS_TMP"' EXIT
printf '# HELP homelab_smart_device_healthy SMART overall health (1 healthy, 0 failed)\n' >> "$METRICS_TMP"
printf '# TYPE homelab_smart_device_healthy gauge\n' >> "$METRICS_TMP"
lsblk -dn -o NAME,TYPE | while read -r name type; do
[ "$type" = "disk" ] || continue
device="/dev/$name"
json=$(smartctl -a -j "$device" 2>/dev/null || true)
[ -n "$json" ] || continue
healthy=$(printf '%s' "$json" | jq -r 'if .smart_status.passed == true then 1 else 0 end')
temperature=$(printf '%s' "$json" | jq -r '.temperature.current // .nvme_smart_health_information_log.temperature // empty')
nvme_warning=$(printf '%s' "$json" | jq -r '.nvme_smart_health_information_log.critical_warning // empty')
printf 'homelab_smart_device_healthy{device="%s"} %s\n' "$name" "$healthy" >> "$METRICS_TMP"
[ -z "$temperature" ] || printf 'homelab_smart_temperature_celsius{device="%s"} %s\n' "$name" "$temperature" >> "$METRICS_TMP"
[ -z "$nvme_warning" ] || printf 'homelab_smart_nvme_critical_warning{device="%s"} %s\n' "$name" "$nvme_warning" >> "$METRICS_TMP"
done
chmod 0644 "$METRICS_TMP"
mv "$METRICS_TMP" "$METRICS_FILE"