From 37fcb8691fab6e4cad6278412b8c3777e3be0dc8 Mon Sep 17 00:00:00 2001 From: Corey O'Brien Date: Wed, 10 May 2017 08:32:55 -0400 Subject: [PATCH] metal: add tectonic_ssh_private_key variable Allow users to specify the SSH private key via a variable in cases where ssh-agent isn't available or configured. --- examples/terraform.tfvars.metal | 4 ++++ platforms/metal/remote.tf | 18 ++++++++++-------- platforms/metal/variables.tf | 6 ++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/terraform.tfvars.metal b/examples/terraform.tfvars.metal index b19fa7585a..33ae240d97 100644 --- a/examples/terraform.tfvars.metal +++ b/examples/terraform.tfvars.metal @@ -200,6 +200,10 @@ tectonic_service_cidr = "10.3.0.0/16" // Example: `ssh-rsa AAAB3N...` tectonic_ssh_authorized_key = "" +// (optional) SSH private key file corresponding to tectonic_ssh_authorized_key. If not provided, SSH agent will be used. +// Example: `/root/.ssh/id_rsa` +// tectonic_ssh_private_key_path = "" + // If set to true, a vanilla Kubernetes cluster will be deployed, omitting any Tectonic assets. tectonic_vanilla_k8s = false diff --git a/platforms/metal/remote.tf b/platforms/metal/remote.tf index 2d6cde12a6..2dfe510b95 100644 --- a/platforms/metal/remote.tf +++ b/platforms/metal/remote.tf @@ -2,10 +2,11 @@ resource "null_resource" "kubeconfig" { count = "${length(var.tectonic_metal_controller_domains) + length(var.tectonic_metal_worker_domains)}" connection { - type = "ssh" - host = "${element(concat(var.tectonic_metal_controller_domains, var.tectonic_metal_worker_domains), count.index)}" - user = "core" - timeout = "60m" + type = "ssh" + host = "${element(concat(var.tectonic_metal_controller_domains, var.tectonic_metal_worker_domains), count.index)}" + user = "core" + timeout = "60m" + private_key = "${file(var.tectonic_ssh_private_key_path != "" ? pathexpand(var.tectonic_ssh_private_key_path) : "/dev/null")}" } provisioner "file" { @@ -28,10 +29,11 @@ resource "null_resource" "bootstrap" { depends_on = ["null_resource.kubeconfig"] connection { - type = "ssh" - host = "${element(var.tectonic_metal_controller_domains, 0)}" - user = "core" - timeout = "60m" + type = "ssh" + host = "${element(var.tectonic_metal_controller_domains, 0)}" + user = "core" + timeout = "60m" + private_key = "${file(var.tectonic_ssh_private_key_path != "" ? pathexpand(var.tectonic_ssh_private_key_path) : "/dev/null")}" } provisioner "file" { diff --git a/platforms/metal/variables.tf b/platforms/metal/variables.tf index 14d29de871..52b8a96faf 100644 --- a/platforms/metal/variables.tf +++ b/platforms/metal/variables.tf @@ -185,3 +185,9 @@ SSH public key to use as an authorized key. Example: `ssh-rsa AAAB3N...` EOF } + +variable "tectonic_ssh_private_key_path" { + type = "string" + description = "SSH private key file corresponding to tectonic_ssh_authorized_key. If not provided, SSH agent will be used." + default = "" +}