From 6011c7554470838554a10ea8a596c0df1877c052 Mon Sep 17 00:00:00 2001 From: Alexander Stepchenko Date: Thu, 8 Aug 2024 22:41:12 +0300 Subject: [PATCH] update run.sh --- run.sh | 61 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/run.sh b/run.sh index 8ac691d..a1538a6 100755 --- a/run.sh +++ b/run.sh @@ -1,45 +1,49 @@ -#!/usr/bin/sh +#!/bin/sh set -xeuo pipefail function print_help() { cat < + $0 [] EOF } -if [ "$#" -lt 3 ]; then +if [ "$#" -lt 2 ]; then print_help exit 1 fi -K8S_VERSIONS="1.26 1.27 1.28 1.29 1.30" +function at_err() { + if [ -s tmp/hosts ]; then + cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh-keygen -R {} + fi +} -for k8s_version in $K8S_VERSIONS; do - branch="${1:-"sisyphus"}" - #k8s_version="${2:-"1.28"}" - task_number="${3:-}" - ssh_options="-o IdentitiesOnly=yes -o StrictHostKeyChecking=no" +trap at_err ERR - # Create VMs - python3 ./main.py +branch="$1" +k8s_version="$2" +task_number="${3:-}" +ssh_options="-o IdentitiesOnly=yes -o StrictHostKeyChecking=no" - # let cloud-init update the system or apt won't be able to get the lock - # remove later - sleep 80 +# Create VMs +python3 ./main.py - # Send run/hosts to every vm - 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 $ssh_options root@{} "systemctl restart network" +# Send run/hosts to every vm +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 $ssh_options root@{} "systemctl restart network" +# Add insecure registry entry +cat tmp/hosts | awk '{print $1}' | xargs -I {} ssh $ssh_options root@{} "mkdir -p /etc/containers/registries.conf.d" +cat tmp/hosts | awk '{print $1}' | xargs -I {} scp $ssh_options 001-insecure-registries.conf root@{}:/etc/containers/registries.conf.d/001-insecure-registries.conf - ansible-playbook ansible/playbook.yaml -i tmp/generated_inventory.yaml \ - -e task_number="$task_number" -e k8s_version="$k8s_version" -e branch="$branch" +ansible-playbook ansible/playbook.yaml -i tmp/generated_inventory.yaml \ + -e branch="$branch" -e k8s_version="$k8s_version" -e task_number="$task_number" - head -n 1 tmp/hosts | awk '{print $1}' | xargs -I {} rsync root@{}:/etc/kubernetes/admin.conf ~/.kube/config +head -n 1 tmp/hosts | awk '{print $1}' | xargs -I {} rsync --mkpath root@{}:/etc/kubernetes/admin.conf ~/.kube/config - kubectl apply -f - <<'EOF' +kubectl apply -f - <