homelab/.github/workflows/vagrant.yml

60 lines
1.7 KiB
YAML
Raw Normal View History

name: homelab-ci
on:
push:
branches:
- main
- testing
jobs:
homelab-ci:
2024-05-02 04:46:17 +00:00
runs-on: macos-13
steps:
- uses: actions/checkout@v3
- name: Cache Vagrant boxes
uses: actions/cache@v3
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-
2024-05-02 04:46:17 +00:00
- name: Install VirtualBox
run: brew install --cask virtualbox
- name: Install Vagrant
run: brew install --cask vagrant
- name: Install Ansible
2024-05-02 04:46:17 +00:00
run: brew install ansible
- name: Software Versions
run: |
2024-05-02 04:46:17 +00:00
printf "VirtualBox "; vboxmanage --version
vagrant --version
ansible --version
- name: Vagrant Up with Dockerbox Playbook
2024-05-02 04:46:17 +00:00
env:
SSH_AUTH_SOCK: ''
run: |
2024-05-02 04:46:17 +00:00
ssh-add -D && echo "[homelab-ci] SSH Agent disabled"
PLAYBOOK=dockerbox vagrant up --debug &
VAGRANT_UP_PID=$!
sleep 30
echo "[homelab-ci] Checking SSH connection availability..."
PRIVATE_KEY="$(find .vagrant -name "private_key" 2>/dev/null | sort)"
HOST_IP="$(vagrant ssh-config | grep HostName | awk '{print $2}')"
echo "[homelab-ci] Private Key: $PRIVATE_KEY"
echo "[homelab-ci] Host IP: $HOST_IP"
echo "[homelab-ci] Running nmap to check open ports..."
nmap -p 22 "$HOST_IP"
echo "[homelab-ci] Attempting raw SSH connection with high verbosity..."
ssh -vvv -i "$PRIVATE_KEY" \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-v vagrant@"$HOST_IP"
wait $VAGRANT_UP_PID