Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of extra reboot and extra checks #13

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 6 additions & 31 deletions modules/domain/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ terraform {
}

resource "proxmox_virtual_environment_vm" "node" {
name = var.name
on_boot = var.autostart
node_name = var.target_node
scsi_hardware = "virtio-scsi-pci"
kvm_arguments = "-fw_cfg name=opt/com.coreos/config,file=/root/ignition/ignition_${var.name}.ign"
timeout_shutdown_vm = 300
reboot = true
name = var.name
on_boot = var.autostart
node_name = var.target_node
scsi_hardware = "virtio-scsi-pci"
kvm_arguments = "-fw_cfg name=opt/com.coreos/config,file=/root/ignition/ignition_${var.name}.ign"

memory {
dedicated = var.memory
Expand All @@ -29,7 +27,7 @@ resource "proxmox_virtual_environment_vm" "node" {

agent {
enabled = true
timeout = "60s"
timeout = "120s"
}

clone {
Expand Down Expand Up @@ -86,26 +84,3 @@ resource "proxmox_virtual_environment_vm" "node" {
when = create
}
}

locals {
non_local_ipv4_address = element([for addresses in proxmox_virtual_environment_vm.node.ipv4_addresses : addresses[0] if addresses[0] != "127.0.0.1"], 0)
}

resource "null_resource" "wait_for_ssh" {
depends_on = [
proxmox_virtual_environment_vm.node
]
provisioner "remote-exec" {
connection {
host = local.non_local_ipv4_address
user = "core"
private_key = file("~/.ssh/id_rsa")
timeout = "5m"
}

inline = [
"# Connected!",
"echo Connected to `hostname`"
]
}
}
2 changes: 1 addition & 1 deletion modules/domain/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "address" {
value = local.non_local_ipv4_address
value = element([for addresses in proxmox_virtual_environment_vm.node.ipv4_addresses : addresses[0] if addresses[0] != "127.0.0.1"], 0)
description = "Non-local IP Address of the node"
}

Expand Down