Make sure ~/.ssh/known_hosts exists before calling ssh-keygen -R

Our vagrant file makes use of ssh-keygen -R to remove any old key
related to an IP address from known_hosts.

But ssh-keygen fails and makes the local.sh exit with failure
(error 2) if the ~/.ssh/known_hosts file does not exist.

Change-Id: I404e79ca644c6c15f51a0f3db6695cc5a895b238
This commit is contained in:
Miguel Angel Ajo 2016-05-23 07:44:17 -04:00
parent ad166aa2b1
commit 8db658b02b
1 changed files with 1 additions and 0 deletions

View File

@ -57,6 +57,7 @@ if is_service_enabled nova; then
IP1=$(nova show node1 | grep "private network" | awk '/private network/ {ip = substr($5, 0, length($5)-1); if (ip ~ "\\.") print ip; else print $6}')
IP2=$(nova show node2 | grep "private network" | awk '/private network/ {ip = substr($5, 0, length($5)-1); if (ip ~ "\\.") print ip; else print $6}')
touch ~/.ssh/known_hosts
ssh-keygen -R ${IP1}
ssh-keygen -R ${IP2}