Sanitized mirror from private repository - 2026-04-20 01:32:01 UTC
This commit is contained in:
11
ansible/automation/scripts/run_healthcheck.sh
Executable file
11
ansible/automation/scripts/run_healthcheck.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# update from git (ignore if local changes)
|
||||
git pull --rebase --autostash || true
|
||||
|
||||
# run playbook and save logs
|
||||
mkdir -p logs
|
||||
ts="$(date +%F_%H-%M-%S)"
|
||||
ansible-playbook playbooks/tailscale_health.yml | tee logs/tailscale_health_${ts}.log
|
||||
45
ansible/automation/scripts/run_weekly.sh
Executable file
45
ansible/automation/scripts/run_weekly.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# Weekly Ansible automation runner
|
||||
# Runs health_check and disk_usage_report across all active hosts.
|
||||
# Installed as a cron job on homelab-vm — runs every Sunday at 06:00.
|
||||
#
|
||||
# Logs: /home/homelab/organized/repos/homelab/ansible/automation/logs/
|
||||
# Alerts: sent via ntfy on any CRITICAL status (configured in health_check.yml)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
AUTOMATION_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
LOG_DIR="$AUTOMATION_DIR/logs"
|
||||
TIMESTAMP="$(date +%F_%H-%M-%S)"
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
echo "=== Weekly Ansible run started: $TIMESTAMP ===" | tee "$LOG_DIR/weekly_${TIMESTAMP}.log"
|
||||
|
||||
# Pull latest repo changes first
|
||||
cd "$(dirname "$(dirname "$AUTOMATION_DIR")")"
|
||||
git pull --rebase --autostash >> "$LOG_DIR/weekly_${TIMESTAMP}.log" 2>&1 || true
|
||||
|
||||
cd "$AUTOMATION_DIR"
|
||||
|
||||
# Skip pi-5-kevin (offline)
|
||||
LIMIT="active:!pi-5-kevin"
|
||||
|
||||
echo "--- Health check ---" | tee -a "$LOG_DIR/weekly_${TIMESTAMP}.log"
|
||||
ansible-playbook playbooks/health_check.yml \
|
||||
-i hosts.ini \
|
||||
--limit "$LIMIT" \
|
||||
-e "ntfy_url=https://ntfy.vish.gg/homelab-alerts" \
|
||||
2>&1 | tee -a "$LOG_DIR/weekly_${TIMESTAMP}.log"
|
||||
|
||||
echo "--- Disk usage report ---" | tee -a "$LOG_DIR/weekly_${TIMESTAMP}.log"
|
||||
ansible-playbook playbooks/disk_usage_report.yml \
|
||||
-i hosts.ini \
|
||||
--limit "$LIMIT" \
|
||||
2>&1 | tee -a "$LOG_DIR/weekly_${TIMESTAMP}.log"
|
||||
|
||||
echo "=== Weekly run complete: $(date +%F_%H-%M-%S) ===" | tee -a "$LOG_DIR/weekly_${TIMESTAMP}.log"
|
||||
|
||||
# Rotate logs — keep last 12 weeks
|
||||
find "$LOG_DIR" -name "weekly_*.log" -mtime +84 -delete
|
||||
Reference in New Issue
Block a user