summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2022-09-13 08:13:47 +0000
committerjerome <jerome@xlinfo.fr>2022-09-13 08:13:47 +0000
commit6ec868c221a183f929d44d93693c6eb576f6bfe8 (patch)
tree3853058c9cf54f5d16cb08c2fea9a2d3785cd59b
parent9046073916438b81169634142ba5db67ea9755f4 (diff)
downloadvbox-0.3.tar.gz
vbox-0.3.zip
Update createvm0.3
-rwxr-xr-xcreatevm14
1 files 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/