refactor: split machine deploys from one-time secrets migration
ansible-core-net / deploy (push) Failing after 39s
ansible-core-secrets / deploy (push) Successful in 30s
ansible-rus-central / deploy (push) Failing after 15s

Roles stay under the machine that runs them, CI applies only a known product, and the /opt/secrets move is a one-shot playbook instead of part of every core-secrets run.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
karpenokandCursor committed 2026-11-10 23:55:34 +07:00
1 parent 341538fba9
commit 9c692522fb
85 files changed
+537 -492

No files matched your search

+12 -43
View File
@@ -5,8 +5,15 @@ on:
branches:
- main
paths:
- 'ansible/roles/core_secrets/**'
- 'ansible/playbooks/core_secrets.yml'
- 'ansible/roles/core-secrets/**'
- 'ansible/roles/host/**'
- 'ansible/playbooks/core-secrets.yml'
- 'ansible/playbooks/migrate-core-secrets.yml'
- 'ansible/playbooks/host.yml'
- 'ansible/playbooks/site.yml'
- 'ansible/inventories/prod/hosts.yml'
- 'ansible/inventories/prod/group_vars/**'
- 'ansible/ci/**'
workflow_dispatch:
jobs:
@@ -14,41 +21,14 @@ jobs:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 15
timeout-minutes: 30
steps:
- name: Деплой core-secrets через Ansible
- name: Деплой core-secrets
env:
INFISICAL_CLIENT_ID: ${{ secrets.INFISICAL_CLIENT_ID }}
INFISICAL_CLIENT_SECRET: ${{ secrets.INFISICAL_CLIENT_SECRET }}
run: |
set -eu
# Прямое подключение к Infisical (CT 901) без зависимости от Traefik
export INFISICAL_PROJECT_ID="806e7f09-5838-492a-946b-2d69b96876ab"
export INFISICAL_DOMAIN="http://192.168.1.102:8080/api"
TOKEN=$(infisical login \
--domain="${INFISICAL_DOMAIN}" \
--method=universal-auth \
--client-id="${INFISICAL_CLIENT_ID}" \
--client-secret="${INFISICAL_CLIENT_SECRET}" \
--plain)
# Подтягиваем SSH-ключ раннера из /ci-cd
eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/ci-cd" --format=dotenv-export --silent)"
# Подтягиваем ключи infisical из /services/infisical
eval "$(infisical export --domain="${INFISICAL_DOMAIN}" --token="${TOKEN}" --env=prod --projectId="${INFISICAL_PROJECT_ID}" --path="/services/infisical" --format=dotenv-export --silent)"
export INFISICAL_POSTGRES_PASSWORD="${POSTGRES_PASSWORD}"
export INFISICAL_ENCRYPTION_KEY="${ENCRYPTION_KEY}"
export INFISICAL_AUTH_SECRET="${AUTH_SECRET}"
if [ -z "${RUNNER_SSH_KEY:-}" ]; then
echo "В Infisical (/ci-cd) отсутствует RUNNER_SSH_KEY" >&2
exit 1
fi
rm -rf "${HOME}/homelab-infra"
git clone http://192.168.1.217:3000/karpenok/homelab-infra.git "${HOME}/homelab-infra"
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
@@ -56,15 +36,4 @@ jobs:
git -C "${HOME}/homelab-infra" checkout "${sha}"
fi
chmod -R go-w "${HOME}/homelab-infra"
install -d -m 700 "${HOME}/.ssh"
printf '%s\n' "${RUNNER_SSH_KEY}" > "${HOME}/.ssh/id_ed25519"
chmod 600 "${HOME}/.ssh/id_ed25519"
eval "$(ssh-agent -s)" >/dev/null
ssh-add "${HOME}/.ssh/id_ed25519" 2>/dev/null
trap 'rm -f "${HOME}/.ssh/id_ed25519"' EXIT
export ANSIBLE_HOST_KEY_CHECKING=False
cd "${HOME}/homelab-infra/ansible"
ansible-playbook -i inventories/prod/hosts.yml playbooks/core_secrets.yml
exec bash "${HOME}/homelab-infra/ansible/ci/deploy-machine.sh" core-secrets "${{ github.event_name }}" "${{ github.event.before }}" "${{ github.sha }}"