From 1ed7932dc967f528768568b53dd149fb3edf07e8 Mon Sep 17 00:00:00 2001 From: Karim Naufal Date: Tue, 25 Jan 2022 13:17:40 +0100 Subject: [PATCH] Revert "make private key optional to support hardware tokens for SSH" --- agents.tf | 6 ++---- master.tf | 8 +++----- servers.tf | 6 ++---- variables.tf | 1 - 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/agents.tf b/agents.tf index c3aff0c..8ca5cc7 100644 --- a/agents.tf +++ b/agents.tf @@ -28,8 +28,7 @@ resource "hcloud_server" "agents" { connection { user = "root" - private_key = var.private_key == null ? null : file(var.private_key) - agent_identity = var.private_key == null ? file(var.public_key) : null + private_key = file(var.private_key) host = self.ipv4_address } } @@ -40,8 +39,7 @@ resource "hcloud_server" "agents" { connection { user = "root" - private_key = var.private_key == null ? null : file(var.private_key) - agent_identity = var.private_key == null ? file(var.public_key) : null + private_key = file(var.private_key) host = self.ipv4_address } } diff --git a/master.tf b/master.tf index 7b957c8..8da0368 100644 --- a/master.tf +++ b/master.tf @@ -24,8 +24,7 @@ resource "hcloud_server" "first_control_plane" { connection { user = "root" - private_key = var.private_key == null ? null : file(var.private_key) - agent_identity = var.private_key == null ? file(var.public_key) : null + private_key = file(var.private_key) host = self.ipv4_address } } @@ -36,8 +35,7 @@ resource "hcloud_server" "first_control_plane" { connection { user = "root" - private_key = var.private_key == null ? null : file(var.private_key) - agent_identity = var.private_key == null ? file(var.public_key) : null + private_key = file(var.private_key) host = self.ipv4_address } } @@ -45,7 +43,7 @@ resource "hcloud_server" "first_control_plane" { # Wait for k3os to be ready and fetch kubeconfig.yaml provisioner "local-exec" { command = <<-EOT - sleep 60 && ping ${self.ipv4_address} | grep --line-buffered "bytes from" | head -1 && sleep 100 && scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${var.private_key == null ? var.public_key : var.private_key} rancher@${self.ipv4_address}:/etc/rancher/k3s/k3s.yaml ${path.module}/kubeconfig.yaml + sleep 60 && ping ${self.ipv4_address} | grep --line-buffered "bytes from" | head -1 && sleep 100 && scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${var.private_key} rancher@${self.ipv4_address}:/etc/rancher/k3s/k3s.yaml ${path.module}/kubeconfig.yaml sed -i -e 's/127.0.0.1/${self.ipv4_address}/g' ${path.module}/kubeconfig.yaml EOT } diff --git a/servers.tf b/servers.tf index 8972903..1510017 100644 --- a/servers.tf +++ b/servers.tf @@ -27,8 +27,7 @@ resource "hcloud_server" "control_planes" { connection { user = "root" - private_key = var.private_key == null ? null : file(var.private_key) - agent_identity = var.private_key == null ? file(var.public_key) : null + private_key = file(var.private_key) host = self.ipv4_address } } @@ -39,8 +38,7 @@ resource "hcloud_server" "control_planes" { connection { user = "root" - private_key = var.private_key == null ? null : file(var.private_key) - agent_identity = var.private_key == null ? file(var.public_key) : null + private_key = file(var.private_key) host = self.ipv4_address } } diff --git a/variables.tf b/variables.tf index 49756b8..4b5c424 100644 --- a/variables.tf +++ b/variables.tf @@ -12,7 +12,6 @@ variable "public_key" { variable "private_key" { description = "SSH private Key." type = string - default = null } variable "location" {