lib.sh: Reuse /tmp/mcp.rsa if present 11/40611/1
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 29 Aug 2017 00:35:37 +0000 (02:35 +0200)
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>
Tue, 29 Aug 2017 19:38:26 +0000 (21:38 +0200)
Long-term, /tmp/mcp.rsa should be moved to a persistent location [1],
and made configurable via env var / other mechanisms.
This will allow us to:
- use an existing keypair (provided by end-user in expected path);
- login to previous deployment machines (e.g. to cleanup UEFI boot
  entries before destroying the cluster and rebuilding it);
- split deploy in re-entrant stages (salt master only, cluster nodes
  only; similar to old Fuel, where we could reuse old Fuel VM);

[1] https://jira.opnfv.org/browse/FUEL-280

Change-Id: I1e53321ed1cfc217ff95e809c867fa3370c479c9
Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
mcp/scripts/lib.sh

index 1b439a9..3f74058 100644 (file)
@@ -9,6 +9,11 @@ generate_ssh_key() {
     user=${SUDO_USER}
   fi
 
+  if [ -f "/tmp/${SSH_KEY}" ]; then
+    cp "/tmp/${SSH_KEY}" .
+    ssh-keygen -f "${SSH_KEY}" -y > "${SSH_KEY}.pub"
+  fi
+
   [ -f "${SSH_KEY}" ] || ssh-keygen -f "${SSH_KEY}" -N ''
   install -o "${user}" -m 0600 "${SSH_KEY}" /tmp/
 }