From 6ec868c221a183f929d44d93693c6eb576f6bfe8 Mon Sep 17 00:00:00 2001 From: jerome Date: Tue, 13 Sep 2022 08:13:47 +0000 Subject: Update createvm --- createvm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/createvm b/createvm index 4b71298..228e978 100755 --- a/createvm +++ b/createvm @@ -15,11 +15,15 @@ echo # On copie notre clé publique, on met à jour le hostname des machines, et on fixe les adresses ip données par le dhcp for ((i=$index;i<$((index+count));i++));do vm=ubuntu$i - while vboxmanage guestproperty get $vm /VirtualBox/GuestInfo/Net/0/V4/IP |grep -q "No value"; do - sleep 5 - echo "Wait VM until ready..." - done - echo -e "\n [$vm ip] $(vboxmanage guestproperty get $vm /VirtualBox/GuestInfo/Net/0/V4/IP)" + # si terraform apply timeout, on attend que la machine ait une adresse ip + if [ "$timeout" == 1 ] ; then + while vboxmanage guestproperty get $vm /VirtualBox/GuestInfo/Net/0/V4/IP |grep -q "No value"; do + sleep 5 + echo "Wait VM until ready..." + done + # on affiche l'adresse ip (pas de terraform output) + echo -e "\n [$vm ip] $(vboxmanage guestproperty get $vm /VirtualBox/GuestInfo/Net/0/V4/IP)" + fi ip_addr=$(vboxmanage guestproperty get $vm /VirtualBox/GuestInfo/Net/0/V4/IP|cut -d ':' -f2) vboxmanage guestcontrol $vm --username vagrant --password vagrant copyto id_rsa.pub /home/vagrant/.ssh/authorized_keys vboxmanage guestcontrol $vm --username vagrant --password vagrant copyto network_config /home/vagrant/ -- cgit v1.2.3