Fix problems when redeploying with osh 26/68326/2
authornikoskarandreas <nick@intracom-telecom.com>
Wed, 7 Aug 2019 14:19:05 +0000 (10:19 -0400)
committerNikos Karandreas <nick@intracom-telecom.com>
Wed, 7 Aug 2019 14:33:31 +0000 (14:33 +0000)
When deploying manually after a previous deployment, keys and fingerprints of the VMs clash with the stored ones.

This patch clears the relevant files and also fixes an issue with keepalived role which failes ansible lint when already cached.

deploy-scenario:k8-calico-nofeature
installer-type:osh

Signed-off-by: nikoskarandreas <nick@intracom-telecom.com>
Change-Id: I9331a5b7d0ac66a35064dfe7f62dd78a461e570c

xci/files/xci-destroy-env.sh
xci/installer/kubespray/deploy.sh
xci/installer/osh/deploy.sh

index 9614846..058d656 100755 (executable)
@@ -21,6 +21,8 @@ rm -rf /opt/stack
 # HOME is normally set by sudo -H
 rm -rf ${HOME}/.config/openstack
 rm -rf ${HOME}/.ansible
+# keepalived role fails ansible lint when cached
+rm -rf ${HOME}/releng-xci/xci/playbooks/roles/keepalived
 # Wipe repos
 rm -rf ${XCI_CACHE}/repos
 
index 48ef745..76d503c 100755 (executable)
@@ -119,16 +119,26 @@ echo "-----------------------------------------------------------------------"
 echo "Info: Kubernetes login details"
 echo "-----------------------------------------------------------------------"
 echo
-# Get the dashborad URL
-DASHBOARD_SERVICE=$(ssh root@$OPNFV_HOST_IP "kubectl get service -n kube-system |grep kubernetes-dashboard")
+# Get the dashboard URL
+if ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -F $OPNFV_HOST_IP;
+then
+ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -R  $OPNFV_HOST_IP;
+echo "known_hosts entry from opnfv host from previous deployment found and deleted"
+fi
+DASHBOARD_SERVICE=$(ssh -q -o StrictHostKeyChecking=no root@$OPNFV_HOST_IP "kubectl get service -n kube-system |grep kubernetes-dashboard")
 DASHBOARD_PORT=$(echo ${DASHBOARD_SERVICE} | awk '{print $5}' |awk -F "[:/]" '{print $2}')
 KUBER_SERVER_URL=$(ssh root@$OPNFV_HOST_IP "grep -r server ~/.kube/config")
 echo "Info: Kubernetes Dashboard URL:"
 echo $KUBER_SERVER_URL | awk '{print $2}'| sed -n "s#:[0-9]*\$#:$DASHBOARD_PORT#p"
 
-# Get the dashborad user and password
+# Get the dashboard user and password
 MASTER_IP=$(echo ${KUBER_SERVER_URL} | awk '{print $2}' |awk -F "[:/]" '{print $4}')
-USER_CSV=$(ssh root@$MASTER_IP " cat /etc/kubernetes/users/known_users.csv")
+if ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -F $MASTER_IP;
+then
+ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -R  $MASTER_IP;
+echo "Info: known_hosts entry for master host from previous deployment found and deleted"
+fi
+USER_CSV=$(ssh -q -o StrictHostKeyChecking=no root@$MASTER_IP " cat /etc/kubernetes/users/known_users.csv")
 USERNAME=$(echo $USER_CSV |awk -F ',' '{print $2}')
 PASSWORD=$(echo $USER_CSV |awk -F ',' '{print $1}')
 echo "Info: Dashboard username: ${USERNAME}"
index 53d4484..73e7130 100755 (executable)
@@ -119,16 +119,26 @@ echo "-----------------------------------------------------------------------"
 echo "Info: Kubernetes login details"
 echo "-----------------------------------------------------------------------"
 echo
-# Get the dashborad URL
-DASHBOARD_SERVICE=$(ssh root@$OPNFV_HOST_IP "kubectl get service -n kube-system |grep kubernetes-dashboard")
+# Get the dashboard URL
+if ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -F $OPNFV_HOST_IP;
+then
+ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -R  $OPNFV_HOST_IP;
+echo "Info: known_hosts entry for opnfv host from previous deployment found and deleted"
+fi
+DASHBOARD_SERVICE=$(ssh -q -o StrictHostKeyChecking=no root@$OPNFV_HOST_IP "kubectl get service -n kube-system |grep kubernetes-dashboard")
 DASHBOARD_PORT=$(echo ${DASHBOARD_SERVICE} | awk '{print $5}' |awk -F "[:/]" '{print $2}')
 KUBER_SERVER_URL=$(ssh root@$OPNFV_HOST_IP "grep -r server ~/.kube/config")
 echo "Info: Kubernetes Dashboard URL:"
 echo $KUBER_SERVER_URL | awk '{print $2}'| sed -n "s#:[0-9]*\$#:$DASHBOARD_PORT#p"
 
-# Get the dashborad user and password
+# Get the dashboard user and password
 MASTER_IP=$(echo ${KUBER_SERVER_URL} | awk '{print $2}' |awk -F "[:/]" '{print $4}')
-USER_CSV=$(ssh root@$MASTER_IP " cat /etc/kubernetes/users/known_users.csv")
+if ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -F $MASTER_IP;
+then
+ssh-keygen -f "/home/opnfv/.ssh/known_hosts" -R  $MASTER_IP;
+echo "Info: known_hosts entry for master host from previous deployment found and deleted"
+fi
+USER_CSV=$(ssh -q -o StrictHostKeyChecking=no root@$MASTER_IP " cat /etc/kubernetes/users/known_users.csv")
 USERNAME=$(echo $USER_CSV |awk -F ',' '{print $2}')
 PASSWORD=$(echo $USER_CSV |awk -F ',' '{print $1}')
 echo "Info: Dashboard username: ${USERNAME}"