feat: run the python script to craete VMs before running the playbook

This commit is contained in:
Александр Степченко 2024-04-29 04:14:52 +03:00
parent 6497719ba9
commit 2edf914267

17
run.sh
View File

@ -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 _