feat(core-secrets): add Ansible role, compose stack, and CI/CD workflow
This commit is contained in:
1 parent
3cefc59aee
commit
4123a7689a
8 files changed
+215
No files matched your search
@@ -0,0 +1,46 @@
|
||||
name: ansible-core-secrets
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'ansible/roles/core_secrets/**'
|
||||
- 'ansible/playbooks/core_secrets.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: homelab
|
||||
container:
|
||||
image: homelab-ansible:latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- name: Деплой core-secrets через 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"
|
||||
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"
|
||||
|
||||
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
|
||||
Reference in new issue
Block a user