testing
This commit is contained in:
parent
324fe0b191
commit
9d4e22dcfd
56
.github/workflows/vagrant.yml
vendored
56
.github/workflows/vagrant.yml
vendored
@ -8,7 +8,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
homelab-ci:
|
homelab-ci:
|
||||||
runs-on: macos-latest
|
runs-on: macos-13
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
@ -21,19 +21,59 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-vagrant-
|
${{ runner.os }}-vagrant-
|
||||||
|
|
||||||
|
- name: Install VirtualBox
|
||||||
|
run: brew install --cask virtualbox
|
||||||
|
|
||||||
|
- name: Install Vagrant
|
||||||
|
run: brew install --cask vagrant
|
||||||
|
|
||||||
- name: Install Ansible
|
- name: Install Ansible
|
||||||
run: brew install ansible@7
|
run: brew install ansible
|
||||||
|
|
||||||
- name: Software Versions
|
- name: Software Versions
|
||||||
run: |
|
run: |
|
||||||
printf "VirtualBox "
|
printf "VirtualBox "; vboxmanage --version
|
||||||
vboxmanage --version
|
|
||||||
vagrant --version
|
vagrant --version
|
||||||
export PATH="/usr/local/opt/ansible@7/bin:$PATH"
|
|
||||||
ansible --version
|
ansible --version
|
||||||
|
|
||||||
|
- name: Install debugging tools
|
||||||
|
run: brew install nmap tree
|
||||||
|
|
||||||
- name: Vagrant Up with Dockerbox Playbook
|
- name: Vagrant Up with Dockerbox Playbook
|
||||||
|
env:
|
||||||
|
SSH_AUTH_SOCK: ''
|
||||||
run: |
|
run: |
|
||||||
export PATH="/usr/local/opt/ansible@7/bin:$PATH"
|
PLAYBOOK=dockerbox vagrant up --debug &
|
||||||
PLAYBOOK=dockerbox vagrant up
|
VAGRANT_UP_PID=$!
|
||||||
vagrant ssh -c "docker ps"
|
DEBUG_ID="[homelab-ci]"
|
||||||
|
echo "$DEBUG_ID Waiting for VM to start..."
|
||||||
|
sleep 60
|
||||||
|
TIMEOUT=600
|
||||||
|
ELAPSED=0
|
||||||
|
SLEEP_DURATION=30
|
||||||
|
SSH_AVAILABLE=0
|
||||||
|
while [[ $ELAPSED -lt $TIMEOUT ]]; do
|
||||||
|
vagrant ssh-config
|
||||||
|
PRIVATE_KEY="$(vagrant ssh-config | grep -E 'IdentityFile.*\.rsa$' | awk '{print $2}')"
|
||||||
|
HOST_IP="$(vagrant ssh-config | grep HostName | awk '{print $2}')"
|
||||||
|
echo "$DEBUG_ID Checking SSH connection availability..."
|
||||||
|
echo "$DEBUG_ID Private Key: $PRIVATE_KEY"
|
||||||
|
echo "$DEBUG_ID Host IP: $HOST_IP"
|
||||||
|
echo "$DEBUG_ID Running nmap to check open ports..."
|
||||||
|
nmap -p 22 "$HOST_IP" | grep "22/tcp open" && SSH_AVAILABLE=1 || SSH_AVAILABLE=0
|
||||||
|
if [[ $SSH_AVAILABLE -eq 1 ]]; then
|
||||||
|
echo "$DEBUG_ID SSH port is open, attempting connection..."
|
||||||
|
ssh -vvv -i "$PRIVATE_KEY" \
|
||||||
|
-o UserKnownHostsFile=/dev/null \
|
||||||
|
-o StrictHostKeyChecking=no \
|
||||||
|
-v vagrant@"$HOST_IP" && break || echo "$DEBUG_ID SSH connection failed, retrying..."
|
||||||
|
else
|
||||||
|
echo "$DEBUG_ID SSH port not open, retrying in $SLEEP_DURATION seconds..."
|
||||||
|
fi
|
||||||
|
sleep $SLEEP_DURATION
|
||||||
|
((ELAPSED+=SLEEP_DURATION))
|
||||||
|
done
|
||||||
|
if [[ $SSH_AVAILABLE -ne 1 ]]; then
|
||||||
|
echo "$DEBUG_ID Timeout reached without successful SSH connection."
|
||||||
|
fi
|
||||||
|
wait $VAGRANT_UP_PID # Ensure the Vagrant up process completes
|
||||||
|
3
Vagrantfile
vendored
3
Vagrantfile
vendored
@ -36,6 +36,7 @@ Vagrant.configure("2") do |config|
|
|||||||
config.vm.provider :virtualbox do |vbox|
|
config.vm.provider :virtualbox do |vbox|
|
||||||
vbox.cpus = VAGRANT_CPUS
|
vbox.cpus = VAGRANT_CPUS
|
||||||
vbox.memory = VAGRANT_MEM
|
vbox.memory = VAGRANT_MEM
|
||||||
|
vbox.gui = true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Provision with Ansible
|
# Provision with Ansible
|
||||||
@ -43,6 +44,6 @@ Vagrant.configure("2") do |config|
|
|||||||
ENV['ANSIBLE_ROLES_PATH'] = File.dirname(__FILE__) + "/roles"
|
ENV['ANSIBLE_ROLES_PATH'] = File.dirname(__FILE__) + "/roles"
|
||||||
ansible.compatibility_mode = "2.0"
|
ansible.compatibility_mode = "2.0"
|
||||||
ansible.playbook = "dev/" + PLAYBOOK + ".yml"
|
ansible.playbook = "dev/" + PLAYBOOK + ".yml"
|
||||||
ansible.raw_arguments = ["--diff"]
|
ansible.raw_arguments = ["--diff", "-vvv"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user