diff options
| -rw-r--r-- | .terraform.tfstate.lock.info | 2 | ||||
| -rwxr-xr-x | createvm | 16 | ||||
| -rw-r--r-- | main.tf | 13 |
3 files changed, 19 insertions, 12 deletions
diff --git a/.terraform.tfstate.lock.info b/.terraform.tfstate.lock.info index 446e4c5..1d6e23b 100644 --- a/.terraform.tfstate.lock.info +++ b/.terraform.tfstate.lock.info @@ -1 +1 @@ -{"ID":"2124f887-5245-88c0-5bb6-7d406c0c3482","Operation":"OperationTypeApply","Info":"","Who":"jerome@jerome-laptop","Version":"1.2.9","Created":"2022-09-11T16:56:46.417100086Z","Path":"terraform.tfstate"}
\ No newline at end of file +{"ID":"e03046f8-ad39-9e8a-a070-e49aa5b7f138","Operation":"OperationTypeApply","Info":"","Who":"jerome@jerome-laptop","Version":"1.2.9","Created":"2022-09-12T19:18:21.247926075Z","Path":"terraform.tfstate"}
\ No newline at end of file @@ -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 @@ -23,12 +23,13 @@ resource "virtualbox_vm" "node" { } } -output "ip_addresses" { - value = { - for vm in virtualbox_vm.node.*: - vm.name => vm.network_adapter.0.ipv4_address - } -} +# bug : timeout... +#output "ip_addresses" { +# value = { +# for vm in virtualbox_vm.node.*: +# vm.name => vm.network_adapter.0.ipv4_address +# } +#} ######################### # Principales commandes # |
