update: enhance Vagrant setup with new scripts for node and workstation installation, and update provisioning to target specific VMs

This commit is contained in:
jon brookes 2025-08-16 11:52:28 +01:00
parent 5f448d7fc7
commit aa912d55df
6 changed files with 79 additions and 23 deletions

View file

@ -1,6 +1,10 @@
#!/usr/bin/env bash
# This script checks for Vagrant and VirtualBox prerequisites, ensures Vagrant VMs are running, and gathers network and system information from the VMs.
# set -euo pipefail
# This script checks for Vagrant and VirtualBox prerequisites,
# ensures Vagrant VMs are running, and gathers network and
# system information from the VMs.
echo "Checking Vagrant prerequisites..."
# Check if Vagrant is installed
@ -20,8 +24,6 @@ else
fi
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "Script directory: $SCRIPT_DIR"
@ -39,8 +41,6 @@ if [ -z "$(vagrant status | grep 'running')" ]; then
vagrant up
fi
network_info=()
vagrant_ports=()
@ -50,12 +50,11 @@ running_vms=$(vagrant status | grep "running" | awk '{print $1}')
for vm in $running_vms; do
# Check network interfaces and get specific IPs
vm_ips=$(vagrant ssh "$vm" -c "ip -j addr" | jq -r '.[] |
select(.addr_info != null) |
vm_ips=$(vagrant ssh "$vm" -c "ip -j addr | jq -r '.[] |
select(.ifname==\"enp0s8\") |
.addr_info[] |
select(.family == "inet" and (.local | startswith("'${VAGRANT_NETWORK_PREFIX:-192.168.56}'."))) |
.local')
select(.family==\"inet\" and .scope==\"global\" and .prefixlen<32 and .local!=\"'${VAGRANT_NETWORK_PREFIX:-192.168.56.250}'\") |
.local'")
# Save the VM's IP to the array if it matches our pattern
if [ ! -z "$vm_ips" ]; then
@ -74,11 +73,6 @@ done
echo "Network information gathered successfully."
# get vagrant ports
# echo "Gathering Vagrant port information..."
# Ensure unique ports are added to the vagrant_ports array
add_unique_port() {
local port=$1
@ -97,13 +91,11 @@ while read -r line; do
done < <(vagrant ssh-config | grep Port)
while read -r line; do
# Extract the port number
port=$(echo "$line" | awk '{print $2}')
add_unique_port "$port"
done < <(vagrant ssh-config | grep Port)
ips=()
# Print network information
for info in "${network_info[@]}"; do