From 14b77f458ae58b6de132110a8a4fe54065cf0f4a Mon Sep 17 00:00:00 2001 From: jerome Date: Mon, 12 Sep 2022 21:19:27 +0200 Subject: update main.tf createvm --- createvm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'createvm') 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 -- cgit v1.2.3