diff --git a/Documentation/design/installconfig.md b/Documentation/design/installconfig.md index 050d0fa9203..2b0bab05e89 100644 --- a/Documentation/design/installconfig.md +++ b/Documentation/design/installconfig.md @@ -68,7 +68,6 @@ type AWS struct { Master `json:",inline" yaml:"master,omitempty"` Profile string `json:"tectonic_aws_profile,omitempty" yaml:"profile,omitempty"` Region string `json:"tectonic_aws_region,omitempty" yaml:"region,omitempty"` - SSHKey string `json:"tectonic_aws_ssh_key,omitempty" yaml:"sshKey,omitempty"` VPCCIDRBlock string `json:"tectonic_aws_vpc_cidr_block,omitempty" yaml:"vpcCIDRBlock,omitempty"` Worker `json:",inline" yaml:"worker,omitempty"` } @@ -106,7 +105,6 @@ type Worker struct { ```go type Libvirt struct { URI string `json:"tectonic_libvirt_uri,omitempty" yaml:"uri"` - SSHKey string `json:"tectonic_libvirt_ssh_key,omitempty" yaml:"sshKey"` QCOWImagePath string `json:"tectonic_coreos_qcow_path,omitempty" yaml:"imagePath"` Network `json:",inline" yaml:"network"` MasterIPs []string `json:"tectonic_libvirt_master_ips,omitempty" yaml:"masterIPs"` diff --git a/config.tf b/config.tf index 9ca2acd57bc..3d14025ba71 100644 --- a/config.tf +++ b/config.tf @@ -267,6 +267,15 @@ also be escaped. EOF } +variable "tectonic_admin_ssh_key" { + type = "string" + default = "" + + description = <${var.tectonic_cluster_name}-api${var.tectonic_cluster_name}-tnc\" --live --config" + command = "virsh -c ${var.tectonic_libvirt_uri} net-update ${var.tectonic_libvirt_network_name} add dns-host \"${var.tectonic_cluster_name}-api${var.tectonic_cluster_name}-tnc\" --live --config" } } diff --git a/steps/topology/libvirt/main.tf b/steps/topology/libvirt/main.tf index 9a5f1d6a155..1b2deb29523 100644 --- a/steps/topology/libvirt/main.tf +++ b/steps/topology/libvirt/main.tf @@ -1,5 +1,5 @@ provider "libvirt" { - uri = "qemu:///system" #XXX fixme + uri = "${var.tectonic_libvirt_uri}" } # Create the bridge for libvirt @@ -34,6 +34,6 @@ locals { # This is currently limited to the first worker, due to an issue with net-update, even though libvirt supports multiple a-records resource "null_resource" "console_dns" { provisioner "local-exec" { - command = "virsh -c qemu:///system net-update ${var.tectonic_libvirt_network_name} add dns-host \"${var.tectonic_cluster_name}\" --live --config" + command = "virsh -c ${var.tectonic_libvirt_uri} net-update ${var.tectonic_libvirt_network_name} add dns-host \"${var.tectonic_cluster_name}\" --live --config" } } diff --git a/steps/variables-aws.tf b/steps/variables-aws.tf index f998e13886f..9f8fe05e99d 100644 --- a/steps/variables-aws.tf +++ b/steps/variables-aws.tf @@ -15,11 +15,6 @@ EOF type = "string" } -variable "tectonic_aws_ssh_key" { - type = "string" - description = "Name of an SSH key located within the AWS region. Example: coreos-user." -} - variable "tectonic_aws_master_ec2_type" { type = "string" description = "Instance size for the master node(s). Example: `t2.medium`." diff --git a/steps/variables-libvirt.tf b/steps/variables-libvirt.tf index bc0cf10a5b9..0a82983ec38 100644 --- a/steps/variables-libvirt.tf +++ b/steps/variables-libvirt.tf @@ -1,6 +1,6 @@ -variable "tectonic_libvirt_ssh_key" { +variable "tectonic_libvirt_uri" { type = "string" - description = "Contents of an SSH key to install for the core user" + description = "libvirt connection URI" } variable "tectonic_libvirt_network_name" { diff --git a/tests/run.sh b/tests/run.sh index 461c845d696..5d824a3360a 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -1,6 +1,8 @@ -#!/bin/bash -e +#!/usr/bin/env bash #shellcheck disable=SC2155 +set -e + # This should be executed from top-level directory not from `tests` directory # Script needs two variables to be set before execution # 1) LICENSE_PATH - path to tectonic license file @@ -18,9 +20,8 @@ CLUSTER_NAME=$(echo "${PREFIX}-$(uuidgen -r | cut -c1-5)" | tr '[:upper:]' '[:lo exec &> >(tee -a "$CLUSTER_NAME.log") function destroy() { - echo -e "\\e[34m Exiting... Destroying Tectonic and cleaning SSH keys...\\e[0m" + echo -e "\\e[34m Exiting... Destroying Tectonic...\\e[0m" tectonic destroy --dir="${CLUSTER_NAME}" - aws ec2 delete-key-pair --key-name "${CLUSTER_NAME}" echo -e "\\e[36m Finished! Smoke test output:\\e[0m ${SMOKE_TEST_OUTPUT}" echo -e "\\e[34m So Long, and Thanks for All the Fish\\e[0m" } @@ -66,13 +67,12 @@ export AWS_ACCESS_KEY_ID=$(echo "${RES}" | jq --raw-output '.Credentials.Access export AWS_SESSION_TOKEN=$(echo "${RES}" | jq --raw-output '.Credentials.SessionToken') ### HANDLE SSH KEY ### -echo -e "\\e[36m Uploading SSH key-pair to AWS...\\e[0m" -if [ ! -f "$HOME/.ssh/id_rsa.pub" ]; then +echo -e "\\e[36m Generating SSH key-pair...\\e[0m" +if [ ! -f ~/.ssh/id_rsa.pub ]; then #shellcheck disable=SC2034 - SSH=$(ssh-keygen -b 2048 -t rsa -f "${HOME}/.ssh/id_rsa" -N "" < /dev/zero) + SSH=$(ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -N "" < /dev/zero) fi -aws ec2 import-key-pair --key-name "${CLUSTER_NAME}" --public-key-material "file://$HOME/.ssh/id_rsa.pub" -export TF_VAR_tectonic_aws_ssh_key="${CLUSTER_NAME}" +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}" diff --git a/tests/smoke/aws/README.md b/tests/smoke/aws/README.md index a2e801d41a6..6bbcce2902f 100644 --- a/tests/smoke/aws/README.md +++ b/tests/smoke/aws/README.md @@ -20,8 +20,7 @@ To begin, verify that the following environment variables are set: - `AWS_PROFILE` or alternatively `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`: These credentials are used by Terraform to spawn clusters on AWS. - `TF_VAR_tectonic_pull_secret_path` and `TF_VAR_tectonic_license_path`: The local path to the pull secret and Tectonic license file. -- `TF_VAR_tectonic_aws_ssh_key`: The AWS ssh key pair which enables ssh'ing into the created machines using the `core` user. - It must be present in AWS under "EC2 -> Network & Security -> Key Pairs". +- (optional) `TF_VAR_tectonic_admin_ssh_key`: The SSH public key which enables SSHing into the created machines using the `core` user. - (optional) `BUILD_ID`: Any number >= 1. Based on this number the region will be selected of the deployed cluster. See the `REGIONS` variable under `smoke.sh` for details. - (optional) `BRANCH_NAME`: The local branch name used as an infix for cluster names. @@ -33,7 +32,7 @@ export AWS_ACCESS_KEY_ID=AKIAIQ5TVFGQ7CKWD6IA export AWS_SECRET_ACCESS_KEY_ID=rtp62V7H/JDY3cNBAs5vA0coaTou/OQbqJk96Hws export TF_VAR_tectonic_license_path="/home/user/tectonic-license" export TF_VAR_tectonic_pull_secret_path="/home/user/coreos-inc/pull-secret" -export TF_VAR_tectonic_aws_ssh_key="user" +export TF_VAR_tectonic_admin_ssh_key="ssh-ed25519 AAAA..." ``` ## Assume Role