diff options
Diffstat (limited to 'createvm')
| -rwxr-xr-x | createvm | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -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/ |
