Set-OPS-Public/roles/client_metrique/templates/setops-node-exporter-cert-sync.sh.j2
Daniel Allaire e648009b87 Zéro-confiance : flux Métriques chiffré (node_exporter TLS + scrape https)
node_exporter sert en HTTPS via le cert step-ca (--web.config.file +
cert-sync owned prometheus, motif .path). Prometheus scrape en scheme https
+ tls_config (ca=root_ca), vérifie contre l'IP en SAN. Vars :
client_metrique_tls_actif, serveur_prometheus_metriques_tls.

Prouvé : node_exporter HTTPS 200 (vérif root_ca), HTTP rejeté (400),
4 cibles Prometheus UP en https sans erreur.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-04 21:04:40 -04:00

18 lines
789 B
Django/Jinja

#!/bin/sh
# Gere par Set-OPS (role client_metrique). Ne pas editer a la main.
# Synchronise le cert step_ca (client_pki, root:root) vers un emplacement lisible
# par 'prometheus' (l'user de node_exporter). Cle en 0600. Idempotent ; appele au
# deploiement ET au renouvellement (unite .path).
set -eu
SRC_CERT="{{ client_metrique_tls_source_cert }}"
SRC_KEY="{{ client_metrique_tls_source_cle }}"
DST="{{ client_metrique_tls_dir }}"
[ -f "$SRC_CERT" ] && [ -f "$SRC_KEY" ] || exit 0
install -o prometheus -g prometheus -m 0644 "$SRC_CERT" "$DST/node.crt"
install -o prometheus -g prometheus -m 0600 "$SRC_KEY" "$DST/node.key"
# node_exporter (exporter-toolkit) relit le cert a chaud ; un reload suffit.
systemctl try-reload-or-restart {{ client_metrique_service }} 2>/dev/null || true