Skip to content

Commit

Permalink
tests/run: Inject the SSH key via the YAML config
Browse files Browse the repository at this point in the history
The TF_VAR_* approach to SSH handling dates back to the initial script
from a2405e4 (run smoke tests with bash script, 2018-06-18,
coreos/tectonic-installer#3284).  But since the current installer
(installer/cmd/tectonic) and the next-gen installer
(cmd/openshift-install) have established channels for passing in the
SSH public key, there's no need to reach around and poke Terraform
directly.

I'm loading the file content from Python to avoid issues with escaping
strings that are passed in via POSIX parameter expansion.
  • Loading branch information
wking committed Sep 4, 2018
1 parent 136752a commit 838fd3f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ cp bazel-bin/tests/smoke/linux_amd64_stripped/go_default_test tectonic-dev/smoke
export PATH="${PWD}/tectonic-dev/installer:${PATH}"
cd tectonic-dev

### HANDLE SSH KEY ###
if [ ! -f ~/.ssh/id_rsa.pub ]; then
echo -e "\\e[36m Generating SSH key-pair...\\e[0m"
ssh-keygen -qb 2048 -t rsa -f ~/.ssh/id_rsa -N "" </dev/zero
fi

if test -z "${AWS_REGION+x}"
then
echo -e "\\e[36m Calculating the AWS region...\\e[0m"
Expand All @@ -59,13 +65,16 @@ CONFIGURE_AWS_ROLES=False
echo -e "\\e[36m Creating Tectonic configuration...\\e[0m"
python <<-EOF >"${CLUSTER_NAME}.yaml"
import datetime
import os.path
import sys
import yaml
with open('examples/tectonic.aws.yaml') as f:
config = yaml.load(f)
config['name'] = '${CLUSTER_NAME}'
with open(os.path.expanduser(os.path.join('~', '.ssh', 'id_rsa.pub'))) as f:
config['admin']['sshKey'] = f.read()
config['baseDomain'] = '${DOMAIN}'
config['pullSecretPath'] = '${PULL_SECRET_PATH}'
config['aws']['region'] = '${AWS_REGION}'
Expand All @@ -83,13 +92,6 @@ python <<-EOF >"${CLUSTER_NAME}.yaml"
echo -e "\\e[36m Initializing Tectonic...\\e[0m"
tectonic init --config="${CLUSTER_NAME}".yaml

### HANDLE SSH KEY ###
if [ ! -f ~/.ssh/id_rsa.pub ]; then
echo -e "\\e[36m Generating SSH key-pair...\\e[0m"
ssh-keygen -qb 2048 -t rsa -f ~/.ssh/id_rsa -N "" </dev/zero
fi
export TF_VAR_tectonic_admin_ssh_key="$(cat ~/.ssh/id_rsa.pub)"

echo -e "\\e[36m Deploying Tectonic...\\e[0m"
tectonic install --dir="${CLUSTER_NAME}"
echo -e "\\e[36m Running smoke test...\\e[0m"
Expand Down

0 comments on commit 838fd3f

Please sign in to comment.