From 2edf914267afc6db28f7fdc73a10083399d6b4f9 Mon Sep 17 00:00:00 2001 From: Alexander Stepchenko Date: Mon, 29 Apr 2024 04:14:52 +0300 Subject: [PATCH] feat: run the python script to craete VMs before running the playbook --- run.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/run.sh b/run.sh index a379085..4293017 100755 --- a/run.sh +++ b/run.sh @@ -3,11 +3,19 @@ branch="${1:-"sisyphus"}" k8s_version="${2:-"1.28"}" task_number="${3:-}" +ssh_options="-o IdentitiesOnly=yes -o StrictHostKeyChecking=no" + +# Create VMs +python3 ./main.py + +# let cloud-init update the system or apt won't be able to get the lock +# remove later +sleep 80 # Send run/hosts to every vm -cat tmp/hosts | awk '{print $1}' | xargs -I _ rsync tmp/hosts root@_:/etc/hosts +cat tmp/hosts | awk '{print $1}' | xargs -I _ rsync -e "ssh $ssh_options" tmp/hosts root@_:/etc/hosts # Restart network on every vm -cat tmp/hosts | awk '{print $1}' | xargs -I _ ssh root@_ "systemctl restart network" +cat tmp/hosts | awk '{print $1}' | xargs -I _ ssh $ssh_options root@_ "systemctl restart network" ansible-playbook ansible/playbook.yaml -i tmp/generated_inventory.yaml \ -e task_number="$task_number" -e k8s_version="$k8s_version" -e branch="$branch" @@ -53,7 +61,10 @@ spec: app: nginx EOF -sleep 180 +sleep 120 head -n 1 tmp/hosts | awk '{print $1}' | xargs -I _ curl _:30007 kubectl exec $(kubectl get po | awk 'END{print $1}') -- nslookup nginx + +# Remove ip addresses from known_hosts +cat tmp/hosts | awk '{print $1}' | xargs -I _ ssh-keygen -R _