dns_resolver role, update-dns script, dns-deploy playbook, inventory updates
This commit is contained in:
parent
152edb8345
commit
1509daad4c
26 changed files with 780 additions and 176 deletions
29
scripts/update-dns.sh
Executable file
29
scripts/update-dns.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
# Generiert /etc/dnsmasq.hosts aus dem Ansible Inventory
|
||||
# Usage: ./update-dns.sh [--apply]
|
||||
|
||||
INI="/app-config/ansible/pfannkuchen.ini"
|
||||
OUT="/etc/dnsmasq.hosts"
|
||||
|
||||
TMP=$(mktemp)
|
||||
echo "# Auto-generated from pfannkuchen.ini" > "$TMP"
|
||||
echo "# $(date)" >> "$TMP"
|
||||
|
||||
grep "ansible_host=" "$INI" | while read line; do
|
||||
name=$(echo "$line" | awk '{print $1}')
|
||||
ip=$(echo "$line" | grep -oP 'ansible_host=\K[0-9.]+')
|
||||
[ -n "$ip" ] && echo "$ip $name" >> "$TMP"
|
||||
done
|
||||
|
||||
if [ "$1" = "--apply" ]; then
|
||||
sudo cp "$TMP" "$OUT"
|
||||
sudo systemctl restart dnsmasq
|
||||
COUNT=$(grep -cP '^\d' "$OUT")
|
||||
echo "✅ ${COUNT} Hosts → dnsmasq aktualisiert"
|
||||
else
|
||||
echo "Preview:"
|
||||
cat "$TMP"
|
||||
echo ""
|
||||
echo "→ Mit --apply übernehmen"
|
||||
fi
|
||||
rm -f "$TMP"
|
||||
Loading…
Add table
Add a link
Reference in a new issue