summaryrefslogtreecommitdiff
path: root/createvm
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2022-09-13 01:25:49 +0200
committerjerome <jerome@xlinfo.fr>2022-09-13 01:25:49 +0200
commite48fdf8a4c5ed73f13c9a8cdef9fe4916b9afd7f (patch)
tree17602711902bb429d2ccd1706eb947f038cc7b1b /createvm
parent1b3a9f8a0518d3f895ebb63511fe1318e72f82e0 (diff)
downloadvbox-e48fdf8a4c5ed73f13c9a8cdef9fe4916b9afd7f.tar.gz
vbox-e48fdf8a4c5ed73f13c9a8cdef9fe4916b9afd7f.zip
update tag 0.2
Diffstat (limited to 'createvm')
-rwxr-xr-xcreatevm24
1 files changed, 12 insertions, 12 deletions
diff --git a/createvm b/createvm
index 9c193fa..4b71298 100755
--- a/createvm
+++ b/createvm
@@ -8,21 +8,21 @@ count=1
# Déploiment terraform
terraform init -reconfigure
terraform plan
-terraform apply -var "nb=$count" -var "start=$index" -auto-approve
+terraform apply -var "nb=$count" -var "start=$index" -auto-approve 2>/dev/null
echo
-# On copie notre clé publique et on met à jour le hostname des machines
+# 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)"
- 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)"
+ 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/
+ vboxmanage guestcontrol $vm --username vagrant --password vagrant run /usr/bin/bash /home/vagrant/network_config $vm $ip_addr
done
echo
-