init main

This commit is contained in:
Super User
2025-07-20 09:58:36 +07:00
committed by Dmitrii Trotskii
commit 0f505b0134
6 changed files with 157 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
name: Run Ansible Playbook
on:
workflow_dispatch:
inputs:
force:
type: boolean
description: "Force re-install"
required: true
default: false
version:
description: "Golang version"
required: true
target:
description: "Target hosts"
required: true
default: "homelab"
type: choice
options:
- "all"
- "homelab"
jobs:
ansible-job:
runs-on: homelab
container:
image: dtrotskiy/ansible
steps:
- name: 🔑 Configure SSH access
run: |
set -e
echo "🧰 Setting up SSH key for Ansible connection..."
mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
echo "✅ SSH key configured successfully."
- name: 📦 Install required packages
run: |
set -e
echo "📦 Installing required packages: git, openssh, nodejs, npm..."
apk add --no-cache git openssh nodejs npm > /dev/null
echo ""
echo "🟢 Versions summary:"
echo " • Git: $(git --version)"
echo " • Node.js: $(node -v)"
echo " • npm: $(npm -v)"
echo " • Ansible: $(ansible --version | head -n1)"
echo ""
echo "✅ Environment setup complete."
- name: 🌀 Clone repository
run: |
set -e
echo "⬇️ Cloning repository from Gitea..."
git clone https://gitea.bwonsamdi.ru/HomeLab/gonfig.git temp
echo "✅ Repository cloned into ./temp"
- name: 🔍 Verify Ansible connectivity
run: |
set -e
echo "🔍 Checking connection to target '${{ inputs.target }}'..."
ansible all -m ping -i ./temp/homelab --limit "${{ inputs.target }}"
echo "✅ Ansible connectivity check passed."
- name: 🚀 Execute Ansible playbook
run: |
set -e
echo "🚀 Running Ansible playbook for target '${{ inputs.target }}'..."
ansible-playbook ./temp/playbook.yml \
-i ./temp/homelab \
--limit "${{ inputs.target }}" \
-e "go_version=${{ inputs.version }} force=${{ inputs.force }}"
echo "🎉 Playbook execution completed successfully!"