propagate ssh key

Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
Kiara Grouwstra 2025-10-13 18:01:18 +02:00
parent 225e66f9ad
commit eb8ce98fdc
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
5 changed files with 18 additions and 8 deletions

View file

@ -25,6 +25,10 @@ in
description = "environment variables to configure the TF HTTP back-end, see <https://developer.hashicorp.com/terraform/language/backend/http#configuration-variables>";
type = types.attrsOf (types.either types.str types.int);
};
key-file = mkOption {
type = types.str;
default = "";
};
proxmox-user = mkOption {
description = "The ProxmoX user to use.";
type = types.str;

View file

@ -24,6 +24,7 @@ let
pathToRoot
targetSystem
sshOpts
key-file
httpBackend
proxmox-user
proxmox-password
@ -262,8 +263,7 @@ let
ssh = {
username = "root";
host = nodeName;
key-file = null;
inherit sshOpts;
inherit key-file sshOpts;
};
module = self;
inherit args deployment-name;
@ -312,8 +312,7 @@ let
ssh = {
username = "root";
host = nodeName;
key-file = null;
inherit sshOpts;
inherit key-file sshOpts;
};
module = self;
inherit args deployment-name httpBackend;
@ -338,8 +337,7 @@ let
ssh = {
username = "root";
host = nodeName;
key-file = null;
inherit sshOpts;
inherit key-file sshOpts;
};
module = self;
inherit

View file

@ -20,6 +20,7 @@ let
nodeName = "pve";
targetSystem = system;
sshOpts = [ ];
key-file = "/root/.ssh/id_ed25519";
proxmox-user = "root@pam";
proxmox-password = "mytestpw";
node-name = "pve";

View file

@ -178,8 +178,14 @@ resource "null_resource" "wait_for_ssh" {
]
provisioner "local-exec" {
command = <<-EOT
for i in $(seq 1 30); do
if ssh -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@${proxmox_virtual_environment_vm.nix_vm.ipv4_addresses[1][0]} "true" 2>/dev/null; then
for i in $(seq 1 10); do
if ssh \
-i "${var.key_file}" \
-o BatchMode=yes \
-o StrictHostKeyChecking=no \
-o ConnectTimeout=1 \
-o ServerAliveInterval=1 \
root@${proxmox_virtual_environment_vm.nix_vm.ipv4_addresses[1][0]} "true"; then
exit 0
fi
echo "Waiting for SSH (attempt #$i)..."

View file

@ -92,6 +92,7 @@
name = "root";
};
sshOpts = [ ];
key-file = "";
proxmox-user = "kiara@ProcoliX";
proxmox-password = "";
node-name = "node051";