summaryrefslogtreecommitdiff
path: root/createvm
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2022-09-12 21:19:27 +0200
committerjerome <jerome@xlinfo.fr>2022-09-12 21:19:27 +0200
commit14b77f458ae58b6de132110a8a4fe54065cf0f4a (patch)
tree8a2fc727ca0bded5c6f8e0ad148c2d1f503f9622 /createvm
parentfe67eba1649523665686f09746b742ba4a97ac72 (diff)
downloadvbox-14b77f458ae58b6de132110a8a4fe54065cf0f4a.tar.gz
vbox-14b77f458ae58b6de132110a8a4fe54065cf0f4a.zip
update main.tf createvm
Diffstat (limited to 'createvm')
-rwxr-xr-xcreatevm16
1 files changed, 11 insertions, 5 deletions
diff --git a/createvm b/createvm
index 509fd90..9c193fa 100755
--- a/createvm
+++ b/createvm
@@ -10,13 +10,19 @@ terraform init -reconfigure
terraform plan
terraform apply -var "nb=$count" -var "start=$index" -auto-approve
-sleep 5
+echo
# On copie notre clé publique et on met à jour le hostname des machines
for ((i=$index;i<$((index+count));i++));do
-vm=ubuntu$i
-vboxmanage guestcontrol $vm --username vagrant --password vagrant copyto id_rsa.pub /home/vagrant/.ssh/authorized_keys
-vboxmanage guestcontrol $vm --username vagrant --password vagrant copyto set-hostname /home/vagrant/set-hostname
-vboxmanage guestcontrol $vm --username vagrant --password vagrant run /usr/bin/bash /home/vagrant/set-hostname $vm
+ 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)"
+ vboxmanage guestcontrol $vm --username vagrant --password vagrant copyto id_rsa.pub /home/vagrant/.ssh/authorized_keys
+ vboxmanage guestcontrol $vm --username vagrant --password vagrant copyto set-hostname /home/vagrant/set-hostname
+ vboxmanage guestcontrol $vm --username vagrant --password vagrant run /usr/bin/bash /home/vagrant/set-hostname $vm
done
+echo