ansible-role-prometheus/files/generate-config.sh
2020-05-22 21:17:59 +02:00

20 lines
400 B
Bash

#!/bin/bash
set -euo pipefail
tmpfile=`mktemp`
(
cat /etc/prometheus/conf.d/*.conf
echo "alerting:"
echo " alertmanagers:"
(cat /etc/prometheus/conf.d/alerting/*.conf 2> /dev/null | sed "s/^/ /") || echo ""
echo "scrape_configs:"
cat /etc/prometheus/conf.d/scrape_configs/*.conf
) > $tmpfile
chmod 0644 $tmpfile
mv $tmpfile /etc/prometheus/prometheus.yml
/usr/bin/systemctl reload prometheus