summaryrefslogtreecommitdiff
path: root/createvm
diff options
context:
space:
mode:
Diffstat (limited to 'createvm')
-rwxr-xr-xcreatevm24
1 files changed, 12 insertions, 12 deletions
diff --git a/createvm b/createvm
index 4b71298..9c193fa 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 2>/dev/null
+terraform apply -var "nb=$count" -var "start=$index" -auto-approve
echo
-# On copie notre clé publique, on met à jour le hostname des machines, et on fixe les adresses ip données par le dhcp
+# On copie notre clé publique et on met à jour le hostname des machines
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)"
- 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
+ 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
+