ci: unify into matrix ansible-deploy.yml, add ansible-lint.yml and exit_nodes group
ansible-deploy / plan (push) Successful in 1s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 17s
ansible-lint / lint (push) Failing after 3s
ansible-deploy / deploy (core-mon, ) (push) Successful in 26s
ansible-deploy / deploy (core-net, ) (push) Successful in 52s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 1m18s
ansible-deploy / deploy (opnsense, ) (push) Successful in 9s
ansible-deploy / deploy (rus-central, ) (push) Successful in 52s

This commit is contained in:
karpenok committed 2026-11-15 22:44:34 +07:00
1 parent 189e31e266
commit fd0dcab300
18 files changed
+243 -278

No files matched your search

-37
View File
@@ -1,37 +0,0 @@
name: ansible-core-mon
on:
push:
branches:
- main
paths:
- 'ansible/roles/core-mon/**'
- 'ansible/roles/host/**'
- 'ansible/playbooks/core-mon.yml'
- 'ansible/playbooks/host.yml'
- 'ansible/inventories/prod/host_vars/core-mon.yml'
- 'ansible/inventories/prod/group_vars/**'
workflow_dispatch:
jobs:
deploy:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 30
steps:
- name: Деплой core-mon
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" core-mon "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}"
-39
View File
@@ -1,39 +0,0 @@
name: ansible-core-net
on:
push:
branches:
- main
paths:
- 'ansible/roles/core-net/**'
- 'ansible/roles/agent_vault_service/**'
- 'ansible/roles/netbird_client/**'
- 'ansible/roles/vmagent/**'
- 'ansible/roles/host/**'
- 'ansible/playbooks/core-net.yml'
- 'ansible/playbooks/host.yml'
- 'ansible/inventories/prod/host_vars/core-net.yml'
- 'ansible/inventories/prod/group_vars/**'
workflow_dispatch:
jobs:
deploy:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 45
steps:
- name: Деплой core-net
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" core-net "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}"
-37
View File
@@ -1,37 +0,0 @@
name: ansible-core-secrets
on:
push:
branches:
- main
paths:
- 'ansible/roles/core-secrets/**'
- 'ansible/roles/cadvisor/**'
- 'ansible/roles/host/**'
- 'ansible/playbooks/core-secrets.yml'
- 'ansible/playbooks/host.yml'
- 'ansible/inventories/prod/host_vars/core-secrets.yml'
- 'ansible/inventories/prod/group_vars/**'
workflow_dispatch:
jobs:
deploy:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 30
steps:
- name: Деплой core-secrets
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" core-secrets "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}"
+85
View File
@@ -0,0 +1,85 @@
name: ansible-deploy
on:
push:
branches:
- main
paths:
- 'ansible/**'
paths-ignore:
- 'ansible/ci/**'
workflow_dispatch:
inputs:
machine:
description: 'Целевая машина (или all для полного прогона)'
required: true
default: 'all'
type: choice
options:
- all
- core-net
- core-secrets
- core-mon
- rus-central
- ger-nod-02
- opnsense
tags:
description: 'Необязательный фильтр тегов (например: remnawave, netbird, monitoring)'
required: false
default: ''
type: string
jobs:
plan:
runs-on: homelab
container:
image: homelab-ansible:latest
outputs:
matrix: ${{ steps.calc.outputs.matrix }}
has_targets: ${{ steps.calc.outputs.has_targets }}
steps:
- name: Вычислить затронутые машины
id: calc
env:
EVENT_NAME: ${{ github.event_name }}
EVENT_BEFORE: ${{ github.event.before }}
EVENT_SHA: ${{ github.sha }}
INPUT_MACHINE: ${{ inputs.machine || 'all' }}
INPUT_TAGS: ${{ inputs.tags || '' }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
python3 "${HOME}/homelab-infra/ansible/ci/ansible-plan.py"
deploy:
needs: plan
if: needs.plan.outputs.has_targets == 'true'
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 45
strategy:
fail-fast: false
max-parallel: 1
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
steps:
- name: Деплой ${{ matrix.machine }}
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" \
"${{ matrix.machine }}" "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}" "${{ matrix.tags }}"
-39
View File
@@ -1,39 +0,0 @@
name: ansible-ger-nod-02
on:
push:
branches:
- main
paths:
- 'ansible/roles/netbird_exit_node/**'
- 'ansible/roles/remnanode/**'
- 'ansible/roles/netbird_client/**'
- 'ansible/roles/vmagent/**'
- 'ansible/roles/host/**'
- 'ansible/playbooks/ger-nod-02.yml'
- 'ansible/playbooks/host.yml'
- 'ansible/inventories/prod/host_vars/ger-nod-02.yml'
- 'ansible/inventories/prod/group_vars/**'
workflow_dispatch:
jobs:
deploy:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 45
steps:
- name: Деплой ger-nod-02
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" ger-nod-02 "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}"
+33
View File
@@ -0,0 +1,33 @@
name: ansible-lint
on:
push:
branches:
- main
paths:
- 'ansible/**'
jobs:
lint:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 10
steps:
- name: Проверка синтаксиса скриптов, Python и плейбуков
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
cd "${HOME}/homelab-infra"
sh -n ansible/ci/ansible-target.sh
bash -n ansible/ci/deploy-machine.sh
python3 -m py_compile ansible/ci/ansible-plan.py \
ansible/roles/core-net/remnawave/files/sync_remnawave.py \
ansible/roles/rus-central/netbird/files/sync_access.py
cd ansible
ansible-playbook --syntax-check playbooks/*.yml
-35
View File
@@ -1,35 +0,0 @@
name: ansible-opnsense
on:
push:
branches:
- main
paths:
- 'ansible/roles/opnsense/**'
- 'ansible/playbooks/opnsense.yml'
- 'ansible/inventories/prod/host_vars/opnsense.yml'
- 'ansible/inventories/prod/group_vars/**'
workflow_dispatch:
jobs:
deploy:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 30
steps:
- name: Деплой opnsense
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" opnsense "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}"
-45
View File
@@ -1,45 +0,0 @@
name: ansible-rus-central
on:
push:
branches:
- main
paths:
- 'ansible/roles/agent_vault_service/**'
- 'ansible/roles/rus-central/**'
- 'ansible/roles/cadvisor/**'
- 'ansible/roles/host/**'
- 'ansible/playbooks/rus-central.yml'
- 'ansible/playbooks/host.yml'
- 'ansible/inventories/prod/host_vars/rus-central.yml'
- 'ansible/inventories/prod/group_vars/**'
workflow_dispatch:
inputs:
letsencrypt_email:
description: Почта Let's Encrypt, если её нужно задать отдельно от group_vars
required: false
type: string
default: ""
jobs:
deploy:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 30
steps:
- name: Деплой rus-central
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
INPUT_LETSENCRYPT_EMAIL: ${{ inputs.letsencrypt_email }}
run: |
set -eu
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.105:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
if [ -n "${sha}" ]; then
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" rus-central "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}"
Binary file not shown.
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Вычисляет матрицу затронутых машин для Gitea Actions (ansible-deploy.yml)."""
from __future__ import annotations
import json
import os
import subprocess
import sys
from pathlib import Path
SKIP_PLAYBOOKS = {"site", "host", "core-git"}
def list_machines(playbooks_dir: Path) -> list[str]:
machines = []
for p in sorted(playbooks_dir.glob("*.yml")):
name = p.stem
if name not in SKIP_PLAYBOOKS:
machines.append(name)
return machines
def main() -> int:
event = os.environ.get("EVENT_NAME", "push").strip()
before = os.environ.get("EVENT_BEFORE", "").strip()
after = os.environ.get("EVENT_SHA", "").strip()
input_machine = os.environ.get("INPUT_MACHINE", "all").strip()
input_tags = os.environ.get("INPUT_TAGS", "").strip()
root = Path(__file__).resolve().parents[2]
machines = list_machines(root / "ansible" / "playbooks")
include: list[dict[str, str]] = []
if event == "workflow_dispatch":
selected = machines if input_machine in ("", "all") else [input_machine]
for m in selected:
if m not in machines:
print(f"Неизвестная или запрещённая для CI машина: {m}", file=sys.stderr)
return 2
include.append({"machine": m, "tags": input_tags})
else:
for m in machines:
proc = subprocess.run(
["sh", str(root / "ansible" / "ci" / "ansible-target.sh"), m, event, before, after],
cwd=root,
capture_output=True,
text=True,
check=False,
)
if proc.returncode != 0:
print(proc.stderr, file=sys.stderr, end="")
return proc.returncode
if proc.stdout.strip():
include.append({"machine": m, "tags": ""})
matrix_json = json.dumps({"include": include}, separators=(",", ":"))
has_targets = "true" if include else "false"
print(f"Planned targets: {matrix_json}")
gh_out = os.environ.get("GITHUB_OUTPUT")
if gh_out:
with open(gh_out, "a", encoding="utf-8") as fh:
fh.write(f"matrix={matrix_json}\n")
fh.write(f"has_targets={has_targets}\n")
return 0
if __name__ == "__main__":
raise SystemExit(main())
+25 -28
View File
@@ -1,9 +1,8 @@
#!/bin/sh #!/bin/sh
# Печатает аргументы ansible-playbook для одной машины. # Печатает аргументы ansible-playbook для одной машины.
# Полный прогон только для общих файлов: playbooks/site.yml, --limit, <машина> # Полный прогон только при ручном запуске без тегов или при изменении общих файлов машины:
# Файл роли: playbooks/<машина>.yml, --tags, каталог роли # playbooks/site.yml --limit <машина>
# Тег берётся из каталога ansible/roles/<машина>/<продукт>/ и должен совпадать с тегом в плейбуке машины. # Файл роли: playbooks/<машина>.yml --tags <продукт>
# Файл в roles/<машина>/ вне такого каталога завершает скрипт с кодом 2.
# Коммит без файлов этой машины ничего не печатает и завершается с кодом 0. # Коммит без файлов этой машины ничего не печатает и завершается с кодом 0.
set -eu set -eu
@@ -11,14 +10,18 @@ machine=${1:?machine}
event=${2:-} event=${2:-}
before=${3:-} before=${3:-}
after=${4:-} after=${4:-}
override_tags=${5:-}
case "$machine" in playbook="ansible/playbooks/${machine}.yml"
core-net | core-secrets | core-mon | core-git | rus-central | ger-nod-02 | opnsense) ;; if [ "$machine" = "site" ] || [ "$machine" = "host" ] || [ ! -f "$playbook" ]; then
*) echo "Неизвестная машина: $machine" >&2
echo "Неизвестная машина: $machine" >&2 exit 2
exit 2 fi
;;
esac if [ -n "$override_tags" ]; then
printf '%s\n' "playbooks/${machine}.yml" "--tags" "$override_tags"
exit 0
fi
full=0 full=0
changed="" changed=""
@@ -39,7 +42,6 @@ fi
tags="" tags=""
full_from_files=0 full_from_files=0
unknown=0 unknown=0
playbook="ansible/playbooks/${machine}.yml"
add_tag() { add_tag() {
case ",$tags," in case ",$tags," in
@@ -61,28 +63,23 @@ if [ "$full" -eq 0 ] && [ -n "$changed" ]; then
for file in $changed; do for file in $changed; do
[ -n "$file" ] || continue [ -n "$file" ] || continue
case "$file" in case "$file" in
ansible/ansible.cfg | ansible/ci/* | ansible/roles/host/* | ansible/playbooks/host.yml | ansible/playbooks/site.yml | ansible/playbooks/"$machine".yml | ansible/inventories/prod/hosts.yml | ansible/inventories/prod/group_vars/* | ansible/inventories/prod/host_vars/"$machine".yml) ansible/ansible.cfg | ansible/roles/host/* | ansible/playbooks/host.yml | ansible/playbooks/site.yml | ansible/playbooks/"$machine".yml | ansible/inventories/prod/hosts.yml | ansible/inventories/prod/group_vars/* | ansible/inventories/prod/host_vars/"$machine".yml)
full_from_files=1 full_from_files=1
;; ;;
ansible/roles/netbird_client/*) ansible/roles/netbird_client/* | ansible/roles/netbird_exit_node/*)
case "$machine" in if grep -qE "role: (netbird_client|netbird_exit_node)" "$playbook"; then
core-net | ger-nod-02) add_tag netbird ;; add_tag netbird
esac fi
;;
ansible/roles/netbird_exit_node/*)
case "$machine" in
ger-nod-02) add_tag netbird ;;
esac
;; ;;
ansible/roles/remnanode/*) ansible/roles/remnanode/*)
case "$machine" in if grep -q "role: remnanode" "$playbook"; then
ger-nod-02) add_tag remnanode ;; add_tag remnanode
esac fi
;; ;;
ansible/roles/vmagent/*) ansible/roles/vmagent/*)
case "$machine" in if grep -q "role: vmagent" "$playbook"; then
core-net | ger-nod-02) add_tag vmagent ;; add_tag vmagent
esac fi
;; ;;
ansible/roles/"$machine"/.ci-trigger) ansible/roles/"$machine"/.ci-trigger)
;; ;;
+21 -18
View File
@@ -7,19 +7,22 @@ machine=${1:?machine}
event=${2:-} event=${2:-}
before=${3:-} before=${3:-}
after=${4:-} after=${4:-}
override_tags=${5:-}
root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
case "$machine" in case "$machine" in
core-git) core-git)
echo "core-git с раннера не деплоится: job выполняется на этой же машине и снесёт Gitea вместе с собой. Плейбук — только с рабочей станции." >&2 echo "core-git с раннера не деплоится: job выполняется на этой же машине и снесёт Gitea вместе с собой. Плейбук — только с рабочей станции." >&2
exit 2 exit 2
;; ;;
core-net | core-secrets | core-mon | rus-central | ger-nod-02 | opnsense) ;;
*)
echo "Неизвестная машина: $machine" >&2
exit 2
;;
esac esac
if [ "$machine" = "site" ] || [ "$machine" = "host" ] || [ ! -f "$root/ansible/playbooks/${machine}.yml" ]; then
echo "Неизвестная машина: $machine" >&2
exit 2
fi
if [ -z "${INFISICAL_CLIENT_ID:-}" ] || [ -z "${INFISICAL_CLIENT_SECRET:-}" ]; then if [ -z "${INFISICAL_CLIENT_ID:-}" ] || [ -z "${INFISICAL_CLIENT_SECRET:-}" ]; then
echo "Нет INFISICAL_CLIENT_ID или INFISICAL_CLIENT_SECRET" >&2 echo "Нет INFISICAL_CLIENT_ID или INFISICAL_CLIENT_SECRET" >&2
exit 1 exit 1
@@ -115,10 +118,10 @@ case "$machine" in
export OPNSENSE_API_KEY="${OPNSENSE_API_KEY:-}" export OPNSENSE_API_KEY="${OPNSENSE_API_KEY:-}"
export OPNSENSE_API_SECRET="${OPNSENSE_API_SECRET:-}" export OPNSENSE_API_SECRET="${OPNSENSE_API_SECRET:-}"
;; ;;
ger-nod-02) *-nod-*)
# SECRET_KEY ноды — /services/remnawave (пишет ansible-core-net). # SECRET_KEY ноды — /services/remnawave (пишет ansible-core-net).
eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/services/remnawave" --format=dotenv-export --silent)" eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/services/remnawave" --format=dotenv-export --silent)"
# Стартовый пароль VPS — как ansible_password у rus-central, только из Infisical /VPS. # Стартовый пароль VPS — /VPS/PASS_<MACHINE_UPPER>.
eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/VPS" --format=dotenv-export --silent)" eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/VPS" --format=dotenv-export --silent)"
# CLOUDFLARE_API уже из /ci-cd выше (только A-запись, без DNS-01). # CLOUDFLARE_API уже из /ci-cd выше (только A-запись, без DNS-01).
export REMNANODE_SECRET_KEY="${REMNANODE_SECRET_KEY:-}" export REMNANODE_SECRET_KEY="${REMNANODE_SECRET_KEY:-}"
@@ -126,36 +129,36 @@ case "$machine" in
export NETBIRD_API_TOKEN="${NETBIRD_API_TOKEN:-}" export NETBIRD_API_TOKEN="${NETBIRD_API_TOKEN:-}"
export NETBIRD_REMNAWAVE_SETUP_KEY="${NETBIRD_REMNAWAVE_SETUP_KEY:-}" export NETBIRD_REMNAWAVE_SETUP_KEY="${NETBIRD_REMNAWAVE_SETUP_KEY:-}"
export CLOUDFLARE_API="${CLOUDFLARE_API:-}" export CLOUDFLARE_API="${CLOUDFLARE_API:-}"
export PASS_GER_NOD_02="${PASS_GER_NOD_02:-}" pass_var="PASS_${machine^^}"
pass_var="${pass_var//-/_}"
vps_pass="${!pass_var:-}"
if [ -z "${REMNANODE_SECRET_KEY}" ]; then if [ -z "${REMNANODE_SECRET_KEY}" ]; then
echo "В Infisical (/services/remnawave) нет REMNANODE_SECRET_KEY — сначала прогоните ansible-core-net (роль remnawave)." >&2 echo "В Infisical (/services/remnawave) нет REMNANODE_SECRET_KEY — сначала прогоните core-net (роль remnawave)." >&2
exit 1 exit 1
fi fi
if [ -z "${CLOUDFLARE_API}" ]; then if [ -z "${CLOUDFLARE_API}" ]; then
echo "В Infisical (/ci-cd) нет CLOUDFLARE_API" >&2 echo "В Infisical (/ci-cd) нет CLOUDFLARE_API" >&2
exit 1 exit 1
fi fi
if [ -z "${PASS_GER_NOD_02}" ]; then if [ -z "${vps_pass}" ]; then
echo "В Infisical (/VPS) нет PASS_GER_NOD_02 — нужен для первичного SSH на ger-nod-02" >&2 echo "В Infisical (/VPS) нет ${pass_var} — нужен для первичного SSH на ${machine}" >&2
exit 1 exit 1
fi fi
# sshpass — как при первом прогоне rus-central с ansible_password.
if ! command -v sshpass >/dev/null 2>&1; then if ! command -v sshpass >/dev/null 2>&1; then
apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq sshpass >/dev/null apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq sshpass >/dev/null
fi fi
export ANSIBLE_HOST_KEY_CHECKING=False export ANSIBLE_HOST_KEY_CHECKING=False
ger_extra=$(mktemp) vps_extra=$(mktemp)
python3 -c 'import json,os; print(json.dumps({"ansible_password": os.environ["PASS_GER_NOD_02"]}))' >"$ger_extra" VPS_PASS="$vps_pass" python3 -c 'import json,os; print(json.dumps({"ansible_password": os.environ["VPS_PASS"]}))' >"$vps_extra"
extra+=(-e "@${ger_extra}") extra+=(-e "@${vps_extra}")
trap 'rm -f "${HOME}/.ssh/id_ed25519" "'"$ger_extra"'"' EXIT trap 'rm -f "${HOME}/.ssh/id_ed25519" "'"$vps_extra"'"' EXIT
;; ;;
esac esac
root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
cd "$root" cd "$root"
target_file=$(mktemp) target_file=$(mktemp)
bash ansible/ci/ansible-target.sh "$machine" "$event" "$before" "$after" > "$target_file" bash ansible/ci/ansible-target.sh "$machine" "$event" "$before" "$after" "$override_tags" > "$target_file"
mapfile -t target < "$target_file" mapfile -t target < "$target_file"
rm -f "$target_file" rm -f "$target_file"
+4
View File
@@ -26,3 +26,7 @@ all:
opnsense: opnsense:
ansible_host: 192.168.1.1 ansible_host: 192.168.1.1
ansible_connection: local ansible_connection: local
children:
exit_nodes:
hosts:
ger-nod-02:
@@ -19,3 +19,4 @@ nodes:
selfsteal_domain: "yali.gunis.top" selfsteal_domain: "yali.gunis.top"
xhttp_path: "/xhttp-yali" xhttp_path: "/xhttp-yali"
host_remark: "🇩🇪 ger-nod-02" host_remark: "🇩🇪 ger-nod-02"
@@ -590,3 +590,4 @@ def main() -> int:
if __name__ == "__main__": if __name__ == "__main__":
raise SystemExit(main()) raise SystemExit(main())
@@ -370,3 +370,4 @@
retries: 30 retries: 30
delay: 2 delay: 2
until: (remnawave_sub_health.stdout | trim) == 'healthy' until: (remnawave_sub_health.stdout | trim) == 'healthy'
@@ -57,3 +57,4 @@
remnawave_sync: "{{ remnawave_sync_raw.stdout | from_json }}" remnawave_sync: "{{ remnawave_sync_raw.stdout | from_json }}"
remnawave_xray_checker_url: "{{ (remnawave_sync_raw.stdout | from_json).xray_checker_subscription_url | default('') }}" remnawave_xray_checker_url: "{{ (remnawave_sync_raw.stdout | from_json).xray_checker_subscription_url | default('') }}"
no_log: true no_log: true
@@ -3,3 +3,4 @@ netbird_exit_group: "exit-{{ inventory_hostname }}"
netbird_exit_clients_group: "exit-clients" netbird_exit_clients_group: "exit-clients"
netbird_exit_network_id: "exit-{{ inventory_hostname }}" netbird_exit_network_id: "exit-{{ inventory_hostname }}"
netbird_exit_route_description: "Exit Node {{ inventory_hostname }} (0.0.0.0/0)" netbird_exit_route_description: "Exit Node {{ inventory_hostname }} (0.0.0.0/0)"