summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kulhavy <martin.kulhavy@nokia.com>2017-08-04 17:23:36 +0300
committerMartin Kulhavy <martin.kulhavy@nokia.com>2017-08-04 17:23:36 +0300
commitcc1297789f961b9e45a9381d35e9e97e5d1e551a (patch)
tree33228416d9ec73681d221f405dbc46f38ef2c9e6
parent9466f8cf264aa85dab6807e9689f9b1949385174 (diff)
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 <martin.kulhavy@nokia.com>
-rwxr-xr-xci/03-maasdeploy.sh14
1 files changed, 13 insertions, 1 deletions
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 \