From: Zack Cerza Date: Thu, 24 Mar 2022 23:10:33 +0000 (-0600) Subject: docker-compose: Optionally use an existing SSH key X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=05d496d69292283e35c94512be9464195182895d;p=teuthology.git docker-compose: Optionally use an existing SSH key This will only work with "real" testnodes; with containerized testnodes there's no reason not to use a generated key. Signed-off-by: Zack Cerza --- diff --git a/docs/docker-compose/Dockerfile b/docs/docker-compose/Dockerfile index b4f1494b6b..5b46ea239a 100644 --- a/docs/docker-compose/Dockerfile +++ b/docs/docker-compose/Dockerfile @@ -1,9 +1,10 @@ FROM ubuntu:latest +ARG SSH_PRIVKEY_FILE=id_ed25519 ENV DEBIAN_FRONTEND=noninteractive RUN \ mkdir $HOME/.ssh && \ - touch $HOME/.ssh/id_ed25519 && \ - chmod 600 $HOME/.ssh/id_ed25519 && \ + touch $HOME/.ssh/${SSH_PRIVKEY_FILE} && \ + chmod 600 $HOME/.ssh/${SSH_PRIVKEY_FILE} && \ echo "StrictHostKeyChecking=no" > $HOME/.ssh/config && \ echo "UserKnownHostsFile=/dev/null" >> $HOME/.ssh/config RUN apt-get update && \ diff --git a/docs/docker-compose/docker-compose.yml b/docs/docker-compose/docker-compose.yml index 70866ecd1b..df8477ac02 100644 --- a/docs/docker-compose/docker-compose.yml +++ b/docs/docker-compose/docker-compose.yml @@ -59,7 +59,10 @@ services: ports: - "11300:11300" teuthology: - build: ./teuthology + build: + context: ./teuthology + args: + SSH_PRIVKEY_FILE: $SSH_PRIVKEY_FILE depends_on: paddles: condition: service_healthy @@ -68,6 +71,7 @@ services: - beanstalk environment: SSH_PRIVKEY: + SSH_PRIVKEY_FILE: MACHINE_TYPE: TESTNODES: testnode: diff --git a/docs/docker-compose/start.sh b/docs/docker-compose/start.sh index 22784dd147..f1cba1142f 100755 --- a/docs/docker-compose/start.sh +++ b/docs/docker-compose/start.sh @@ -15,11 +15,17 @@ cp custom_conf.yaml teuthology/ -# Generate an SSH keypair to use -SSH_PRIVKEY_PATH=$(mktemp -u /tmp/teuthology-ssh-key-XXXXXX) -ssh-keygen -t ed25519 -N '' -f $SSH_PRIVKEY_PATH -export SSH_PRIVKEY=$(cat $SSH_PRIVKEY_PATH) -export SSH_PUBKEY=$(cat $SSH_PRIVKEY_PATH.pub) +# Generate an SSH keypair to use if necessary +if [ -z "$SSH_PRIVKEY_PATH" ]; then + SSH_PRIVKEY_PATH=$(mktemp -u /tmp/teuthology-ssh-key-XXXXXX) + ssh-keygen -t ed25519 -N '' -f $SSH_PRIVKEY_PATH + export SSH_PRIVKEY=$(cat $SSH_PRIVKEY_PATH) + export SSH_PUBKEY=$(cat $SSH_PRIVKEY_PATH.pub) + export SSH_PRIVKEY_FILE=id_ed25519 +else + export SSH_PRIVKEY=$(cat $SSH_PRIVKEY_PATH) + export SSH_PRIVKEY_FILE=$(basename $SSH_PRIVKEY_PATH | cut -d. -f1) +fi trap "docker-compose down" SIGINT docker-compose up \ diff --git a/docs/docker-compose/teuthology.sh b/docs/docker-compose/teuthology.sh index ff2250ac06..7fdfd221f4 100755 --- a/docs/docker-compose/teuthology.sh +++ b/docs/docker-compose/teuthology.sh @@ -1,7 +1,8 @@ #!/usr/bin/bash -set -e # We don't want -x yet, in case the private key is sensitive -echo "$SSH_PRIVKEY" > $HOME/.ssh/id_ed25519 +if [ -n "$SSH_PRIVKEY_FILE" ]; then + echo "$SSH_PRIVKEY" > $HOME/.ssh/$SSH_PRIVKEY_FILE +fi source /teuthology/virtualenv/bin/activate set -x if [ -n "$TESTNODES" ]; then