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>"; 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); type = types.attrsOf (types.either types.str types.int);
}; };
key-file = mkOption {
type = types.str;
default = "";
};
proxmox-user = mkOption { proxmox-user = mkOption {
description = "The ProxmoX user to use."; description = "The ProxmoX user to use.";
type = types.str; type = types.str;

View file

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

View file

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

View file

@ -178,8 +178,14 @@ resource "null_resource" "wait_for_ssh" {
] ]
provisioner "local-exec" { provisioner "local-exec" {
command = <<-EOT command = <<-EOT
for i in $(seq 1 30); do for i in $(seq 1 10); 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 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 exit 0
fi fi
echo "Waiting for SSH (attempt #$i)..." echo "Waiting for SSH (attempt #$i)..."

View file

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