forked from fediversity/fediversity
await SSH availability, resolving a race condition
Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
parent
eb39b278a3
commit
d76e0ddb98
2 changed files with 23 additions and 0 deletions
|
|
@ -187,8 +187,30 @@ resource "proxmox_virtual_environment_vm" "nix_vm" {
|
||||||
# }
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "null_resource" "wait_for_ssh" {
|
||||||
|
depends_on = [
|
||||||
|
proxmox_virtual_environment_vm.nix_vm
|
||||||
|
]
|
||||||
|
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
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "Waiting for SSH (attempt #$i)..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
echo "SSH never came up!" >&2
|
||||||
|
exit 1
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# FIXME expose (and handle thru) [`exec`](https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/agent/exec) endpoint in proxmox TF provider? wait, what command would i use it for?: https://github.com/bpg/terraform-provider-proxmox/issues/1576
|
# FIXME expose (and handle thru) [`exec`](https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/agent/exec) endpoint in proxmox TF provider? wait, what command would i use it for?: https://github.com/bpg/terraform-provider-proxmox/issues/1576
|
||||||
module "nixos-rebuild" {
|
module "nixos-rebuild" {
|
||||||
|
depends_on = [
|
||||||
|
null_resource.wait_for_ssh
|
||||||
|
]
|
||||||
source = "../tf-single-host"
|
source = "../tf-single-host"
|
||||||
nixos_conf = var.nixos_conf
|
nixos_conf = var.nixos_conf
|
||||||
# username = var.ssh_user # refers to the proxmox ssh user, not the VM one
|
# username = var.ssh_user # refers to the proxmox ssh user, not the VM one
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ in
|
||||||
).withPlugins
|
).withPlugins
|
||||||
(p: [
|
(p: [
|
||||||
p.external
|
p.external
|
||||||
|
p.null
|
||||||
(mkProvider {
|
(mkProvider {
|
||||||
owner = "bpg";
|
owner = "bpg";
|
||||||
repo = "terraform-provider-proxmox";
|
repo = "terraform-provider-proxmox";
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue