diff options
| author | jerome <jerome@xlinfo.fr> | 2022-09-12 21:19:27 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2022-09-12 21:19:27 +0200 |
| commit | 14b77f458ae58b6de132110a8a4fe54065cf0f4a (patch) | |
| tree | 8a2fc727ca0bded5c6f8e0ad148c2d1f503f9622 /createvm | |
| parent | fe67eba1649523665686f09746b742ba4a97ac72 (diff) | |
| download | vbox-14b77f458ae58b6de132110a8a4fe54065cf0f4a.tar.gz vbox-14b77f458ae58b6de132110a8a4fe54065cf0f4a.zip | |
update main.tf createvm
Diffstat (limited to 'createvm')
| -rwxr-xr-x | createvm | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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 |
