Last active
March 11, 2024 10:04
-
-
Save kkroesch/cfdb589f0c6ce3d17f232a268649a5bc to your computer and use it in GitHub Desktop.
Manage VirtualBox VMs with Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
running_vms=($(VBoxManage list runningvms | awk '{print $1}' | tr -d '"')) | |
# Create Ansible inventory file | |
GROUP_NAME="local_vms" | |
for vm in $running_vms | |
do | |
vboxmanage guestproperty get "$vm" "/VirtualBox/GuestInfo/Net/0/V4/IP" | |
done | | |
awk -v group="$GROUP_NAME" ' | |
BEGIN { printf("[%s]\n", group)} | |
{ print $2 } | |
' > hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment