logging: make host-bound GitOps files reproducibly stageable
The Portainer stack consumes its compose file from Git but bind-mounts runtime configuration from stable paths under /mnt/containers/logging. The stable host copy of docker-compose.yaml had consequently fallen behind the deployed Git revision even though the running stack and dashboard files were current.\n\nAdd a root-run staging/check helper that copies and byte-verifies Compose, Loki, Alloy, syslog-ng, Grafana provisioning, and both dashboards without touching credentials or persistent data. Document the workflow and the final source-restricted passive Agent 2 interfaces for all four Telemt hosts.\n\nValidated with bash -n and git diff --check. Unrelated .DS_Store changes remain untracked/uncommitted.
This commit is contained in:
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
mode="stage"
|
||||
if [[ "${1:-}" == "--check" ]]; then
|
||||
mode="check"
|
||||
shift
|
||||
fi
|
||||
|
||||
target_root="${1:-/mnt/containers/logging}"
|
||||
source_root="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
mappings=(
|
||||
"docker-compose.yaml:docker-compose.yaml"
|
||||
"alloy-config.alloy:alloy-config/config.alloy"
|
||||
"loki-config.yaml:loki-config/config.yaml"
|
||||
"syslog-ng.conf:syslog-ng-config/syslog-ng.conf"
|
||||
"grafana-provisioning/dashboards/dashboards.yaml:grafana-config/provisioning/dashboards/dashboards.yaml"
|
||||
"grafana-provisioning/datasources/loki.yaml:grafana-config/provisioning/datasources/loki.yaml"
|
||||
"grafana-provisioning/datasources/zabbix.yaml:grafana-config/provisioning/datasources/zabbix.yaml"
|
||||
"grafana-dashboards/mikrotik-loki-logs.json:grafana-config/dashboards/mikrotik-loki-logs.json"
|
||||
"grafana-dashboards/telemt-proxy-fleet.json:grafana-config/dashboards/telemt-proxy-fleet.json"
|
||||
)
|
||||
|
||||
if [[ "${mode}" == "stage" ]]; then
|
||||
install -d -m 0755 \
|
||||
"${target_root}/alloy-config" \
|
||||
"${target_root}/loki-config" \
|
||||
"${target_root}/syslog-ng-config" \
|
||||
"${target_root}/grafana-config/provisioning/dashboards" \
|
||||
"${target_root}/grafana-config/provisioning/datasources" \
|
||||
"${target_root}/grafana-config/dashboards"
|
||||
|
||||
install -d -o 0 -g 0 -m 0755 "${target_root}/alloy-data"
|
||||
install -d -o 472 -g 0 -m 0755 "${target_root}/grafana-data"
|
||||
install -d -o 10001 -g 10001 -m 0755 "${target_root}/loki-data"
|
||||
fi
|
||||
|
||||
failed=0
|
||||
for mapping in "${mappings[@]}"; do
|
||||
source_file="${source_root}/${mapping%%:*}"
|
||||
target_file="${target_root}/${mapping#*:}"
|
||||
|
||||
if [[ "${mode}" == "stage" ]]; then
|
||||
install -o root -g root -m 0644 "${source_file}" "${target_file}"
|
||||
fi
|
||||
|
||||
if cmp -s "${source_file}" "${target_file}"; then
|
||||
printf 'OK %s\n' "${target_file}"
|
||||
else
|
||||
printf 'DIFF %s\n' "${target_file}" >&2
|
||||
failed=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "${failed}"
|
||||
Reference in New Issue
Block a user