Files
homelab-infra/.gitea/workflows/ansible-core-net.yml
T

46 lines
1.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: ansible-core-net
on:
workflow_dispatch:
jobs:
deploy:
runs-on: homelab
container:
image: homelab-ansible:latest
timeout-minutes: 15
steps:
- name: Деплой Traefik на core-net через Ansible
env:
RUNNER_SSH_KEY: ${{ secrets.RUNNER_SSH_KEY }}
run: |
set -eu
if [ -z "${RUNNER_SSH_KEY:-}" ]; then
echo "В секретах Gitea отсутствует RUNNER_SSH_KEY" >&2
exit 1
fi
rm -rf "${HOME}/homelab-infra"
# Клонируем по прямому IP Gitea (192.168.1.217:3000), чтобы не зависеть от состояния Traefik/DNS
git clone http://192.168.1.217: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"
# Настраиваем SSH-ключ раннера
install -d -m 700 "${HOME}/.ssh"
printf '%s\n' "${RUNNER_SSH_KEY}" > "${HOME}/.ssh/id_ed25519"
chmod 600 "${HOME}/.ssh/id_ed25519"
trap 'rm -f "${HOME}/.ssh/id_ed25519"' EXIT
cd "${HOME}/homelab-infra/ansible"
export ANSIBLE_HOST_KEY_CHECKING=False
ansible-playbook playbooks/core_net.yml \
-i inventories/prod/hosts.yml \
--private-key "${HOME}/.ssh/id_ed25519"