From: Martin Kulhavy Date: Fri, 4 Aug 2017 14:23:36 +0000 (+0300) Subject: Automatically add the virsh IP to known hosts X-Git-Tag: opnfv-5.0.RC1~83 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=cc1297789f961b9e45a9381d35e9e97e5d1e551a;p=joid.git Automatically add the virsh IP to known hosts During the generation of the bootstrap VM, ssh connection to the host machine is opened. If the IP is not yet in the list of known hosts, the installation blocks and waits for user input. The fix queries the host and adds the ssh fingerprint(s) to the list of known hosts, if it is not present already. Change-Id: I3e4bbb80811ab880e7271970713047c5d4ccca0f Signed-off-by: Martin Kulhavy --- diff --git a/ci/03-maasdeploy.sh b/ci/03-maasdeploy.sh index 58879df4..d2dde1d4 100755 --- a/ci/03-maasdeploy.sh +++ b/ci/03-maasdeploy.sh @@ -345,10 +345,12 @@ addnodes(){ # if we have a virshurl configuration we use it, else we use local VIRSHURL=$(cat labconfig.json | jq -r '.opnfv.virshurl') if ([ $VIRSHURL == "" ] || [ "$VIRSHURL" == "null" ]); then - VIRSHURL="qemu+ssh://$USER@$MAAS_IP/system " + VIRSHIP=$MAAS_IP + VIRSHURL="qemu+ssh://$USER@$VIRSHIP/system " VIRSHHOST="" else VIRSHHOST=$(echo $VIRSHURL| cut -d\/ -f 3 | cut -d@ -f2) + VIRSHIP="" # TODO: parse from $VIRSHURL if needed fi if [ "$virtinstall" -eq 1 ]; then @@ -374,6 +376,16 @@ addnodes(){ done fi + # Add server fingerprint to known hosts to prevent security prompt in the + # SSH connection during the virt-install + if [ $VIRSHIP != "" ]; then + # Check if the IP is not already present among the known hosts + if ! ssh-keygen -F $VIRSHIP > /dev/null ; then + echo "SSH fingerprint of the host is not known yet, adding" + ssh-keyscan -H $VIRSHIP >> ~/.ssh/known_hosts + fi + fi + virt-install --connect $VIRSHURL --name bootstrap --ram 4098 --cpu host --vcpus 2 --video \ cirrus --arch x86_64 --disk size=20,format=qcow2,bus=virtio,cache=directsync,io=native,pool=default \ $netw --boot network,hd,menu=off --noautoconsole \