fix(netbird): вынести адрес машины и домен в inventory

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
karpenokandCursor committed 2026-11-08 01:07:19 +07:00
1 parent bb6bb5969d
commit a23232ac1c
10 files changed
+64 -42

No files matched your search

+19 -24
View File
@@ -46,30 +46,25 @@ jobs:
install -d -m 700 "${HOME}/.ssh"
printf '%s\n' "${RUNNER_SSH_KEY}" > "${HOME}/.ssh/id_ed25519"
chmod 600 "${HOME}/.ssh/id_ed25519"
# Домашний DNS отдаёт central.gunihome.ru на 192.168.1.201. Раннер в этой сети,
# поэтому SSH и проверка идут на публичный адрес VPS.
ssh-keyscan -H 45.154.185.208 >> "${HOME}/.ssh/known_hosts"
cat > /tmp/netbird-inventory.ini <<'EOF'
[netbird]
vps ansible_host=45.154.185.208 ansible_user=root
EOF
ansible-playbook /tmp/homelab-infra/services/netbird/playbook.yml \
-i /tmp/netbird-inventory.ini \
--private-key "${HOME}/.ssh/id_ed25519" \
-e "netbird_letsencrypt_email=${NETBIRD_LETSENCRYPT_EMAIL}"
ready=0
for _ in $(seq 1 30); do
code=$(curl -sk --resolve central.gunihome.ru:443:45.154.185.208 -o /dev/null -w '%{http_code}' https://central.gunihome.ru/ || true)
echo "https://central.gunihome.ru/ через 45.154.185.208 -> ${code}"
if [ "${code}" = "200" ] || [ "${code}" = "302" ]; then
ready=1
break
fi
sleep 10
done
if [ "${ready}" -ne 1 ]; then
echo "Панель не ответила по HTTPS за отведённое время." >&2
inventory=/tmp/homelab-infra/inventory/hosts.ini
target=$(awk '{
for (i = 1; i <= NF; i++) {
if ($i ~ /^ansible_host=/) {
split($i, a, "=")
print a[2]
exit
}
}
}' "${inventory}")
if [ -z "${target}" ]; then
echo "В inventory/hosts.ini нет ansible_host." >&2
exit 1
fi
echo "Цель из inventory: ${target}"
ssh-keyscan -H "${target}" >> "${HOME}/.ssh/known_hosts"
ansible-playbook /tmp/homelab-infra/services/netbird/playbook.yml \
-i "${inventory}" \
--private-key "${HOME}/.ssh/id_ed25519" \
-e "netbird_letsencrypt_email=${NETBIRD_LETSENCRYPT_EMAIL}"