From 1f25762668f36971adda9e09947637aa84a499c3 Mon Sep 17 00:00:00 2001 From: jerome Date: Sun, 11 Sep 2022 18:51:14 +0200 Subject: commit initial --- createvm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 createvm (limited to 'createvm') diff --git a/createvm b/createvm new file mode 100755 index 0000000..509fd90 --- /dev/null +++ b/createvm @@ -0,0 +1,22 @@ +#!/bin/bash + +# Premier numero de la série +index=3 +# Nombre de machines +count=1 + +# Déploiment terraform +terraform init -reconfigure +terraform plan +terraform apply -var "nb=$count" -var "start=$index" -auto-approve + +sleep 5 + +# 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 +done + -- cgit v1.2.3