Ansible playbook added
[eliot.git] / scripts / ci_management / cleanup_centos.sh
1 # !/bin/bash -ex
2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.                                 #
4 #                                                                            #
5 # All rights reserved. This program and the accompanying materials           #
6 # are made available under the terms of the Apache License, Version 2.0      #
7 # which accompanies this distribution, and is available at                   #
8 # http://www.apache.org/licenses/LICENSE-2.0                                 #
9 ##############################################################################
10
11 sudo kubeadm reset
12
13 if [ -f "$HOME/testk8s-nginx.yaml" ]; then
14     cd $HOME && kubectl delete -f test-k8snginx.yaml && rm -rf testk8s-nginx.yaml
15     echo "testk8s-nginx.yaml cleaned"
16 fi
17
18 if [ -d "/var/lib/etcd" ]; then
19     sudo rm -rf /var/lib/etcd
20     echo "etcd cleaned"
21 fi
22
23 KUBEADM_RESET="sudo kubeadm reset"
24 ETCD_CLEAN="sudo rm -rf /var/lib/etcd"
25 CLEANUP_PROM_CADVISOR="cd eliot/scripts/ci_management && ./uninstall_cadvisor.sh"
26
27 # Read all the Worker Node details from nodelist file.
28 echo $(pwd)
29 while read line
30 do
31      nodeinfo="${line}"
32      nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
33      nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
34      nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
35      sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_RESET}
36      sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${ETCD_CLEAN}
37      sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${CLEANUP_PROM_CADVISOR}
38 done < nodelist > /dev/null 2>&1
39