Last active
August 24, 2018 00:49
-
-
Save isaldarriaga/b2de4a889784f0505aa2e9a5fb4002bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ENV=$1 | |
TLD=$2 | |
NET=$3 | |
echo && echo && \ | |
echo "(1/1) Getting server's test script.." && echo && \ | |
wget -nv -O /tmp/test-repo-server.sh "https://gist.githubusercontent.com/isaldarriaga/076632c3e727a197bf9cd40d3064e6e1/raw/87f67e5a472c7c07fd04aa0989ea2c43629d456b/test-repo-server.sh" | |
# YUM | |
for ROLE in "infra" "etcd" "master" "worker" "lb" | |
do | |
# iterate possible ip range | |
for i in {1..10} | |
do | |
# save valid IP | |
dig @"$NET".6 "$ENV-$ROLE-0$i.$TLD" +short | grep $NET > /tmp/repo.ip | |
# iterate valid IP | |
for IP in $(cat /tmp/repo.ip) | |
do | |
echo && \ | |
echo "**************************************************************" && \ | |
echo "REMOTE TEST - STARTED: $(dig @$NET.6 -x $IP +short) ($IP).." && \ | |
echo "**************************************************************" && \ | |
echo "(1/2) copying test script to server .." && echo && \ | |
scp /tmp/test-repo-server.sh "root@$IP:/root/test-repo-server.sh" && \ | |
echo && echo && \ | |
echo "(2/2) running remote test.." && echo && \ | |
ssh "root@$IP" sh /root/test-repo-server.sh | |
echo && \ | |
echo "*********************************************************************************" && \ | |
echo "REMOTE TEST - COMPLETE! $(dig @$NET.6 -x $IP +short) ($IP).." && \ | |
echo "*********************************************************************************" && \ | |
echo && echo | |
echo "About to perform local test (connect to repos defined in server).." && sleep 5s | |
echo && echo && \ | |
echo && \ | |
echo "==============================================================" && \ | |
echo "LOCAL TEST - STARTED: $(dig @$NET.6 -x $IP +short) ($IP).." && \ | |
echo "==============================================================" && echo | |
# save repo files | |
echo "(1/1) getting list of remote repo files .." && echo && \ | |
ssh "root@$IP" find /etc/yum.repos.d/ -type f > /tmp/repo.file | |
# iterate repo files | |
for FILE in $(cat /tmp/repo.file) | |
do | |
echo && \ | |
echo "==============================================================" && \ | |
echo "LOCAL TEST - FILE: $FILE" && \ | |
echo "==============================================================" && echo | |
# save lines | |
echo "(1/2) getting repo file's content .." && echo && \ | |
ssh "root@$IP" cat $FILE > /tmp/repo.line | |
# save urls | |
echo "(2/2) getting valid urls .." && echo && \ | |
cat /tmp/repo.line | grep http | grep -v '\$' | awk -F '=' '{print $2}' > /tmp/repo.url | |
# iterate valid urls | |
for URL in $(cat /tmp/repo.url) | |
do | |
echo && \ | |
echo "------------------------------------------------------------------------------" && \ | |
echo "LOCAL TEST - URL: $URL/repodata/repomd.xml" && \ | |
echo "------------------------------------------------------------------------------" && \ | |
echo | |
# test repo metadata | |
echo "(1/1) running test from local.." && echo && \ | |
wget -nv -O /tmp/repo.xml --tries 1 --timeout 1 "$URL/repodata/repomd.xml" && \ | |
head -n 3 /tmp/repo.xml | |
done | |
done | |
echo && \ | |
echo "*********************************************************************************" && \ | |
echo "LOCAL TEST - COMPLETE! $(dig @$NET.6 -x $IP +short) ($IP).." && \ | |
echo "*********************************************************************************" && \ | |
echo && echo | |
echo "About to perform next remote test.." && sleep 5s | |
done | |
done | |
done | |
# APT | |
# for ROLE in "kube" "rbd" "rbd-mirror" "hdfs" "hdfs-mirror" "data" | |
# do | |
# done | |
# for file in $(find /etc/yum.repos.d/ -type f) | |
# do | |
# echo $file && cat $file | grep -v '\$' | grep http | awk -F '=' '{print $2}' | |
# done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment