homelab/tf/huts.tf

275 lines
5.5 KiB
HCL

resource "proxmox_virtual_environment_vm" "jumper_storage_dummy" {
name = "jumper-dummy"
description = "Managed by Terraform"
tags = ["terraform", "disk-dummy"]
node_name = "pve"
vm_id = 7101
started = false
on_boot = false
disk {
datastore_id = var.proxmox_vm_storage
file_format = "qcow2"
interface = "scsi0"
size = 32
}
}
resource "proxmox_virtual_environment_vm" "jumper" {
# Don't forget to change the cloud init file if this is changed
name = "jumper"
description = "Managed by Terraform"
tags = ["terraform", "ubuntu", "hut"]
node_name = "pve"
vm_id = 7001
cpu {
cores = 4
type = "host"
}
memory {
dedicated = 8192
floating = 8192
}
agent {
enabled = true
}
startup {
order = "1"
up_delay = "60"
down_delay = "60"
}
disk {
datastore_id = var.proxmox_vm_storage
file_id = proxmox_virtual_environment_file.ubuntu_cloud_image.id
interface = "virtio0"
iothread = true
discard = "on"
size = 32
file_format = "qcow2"
}
initialization {
ip_config {
ipv4 {
address = "10.0.44.2/16"
gateway = var.gateway
}
}
datastore_id = var.proxmox_image_storage
user_data_file_id = proxmox_virtual_environment_file.common_cloud_init.id
}
dynamic "disk" {
for_each = { for idx, val in proxmox_virtual_environment_vm.jumper_storage_dummy.disk : idx => val }
iterator = data_disk
content {
datastore_id = data_disk.value["datastore_id"]
path_in_datastore = data_disk.value["path_in_datastore"]
file_format = data_disk.value["file_format"]
size = data_disk.value["size"]
# assign from scsi1 and up
interface = "scsi${data_disk.key + 1}"
}
}
network_device {
bridge = "vmbr0"
}
operating_system {
type = "l26"
}
connection {
type = "ssh"
user = "ubuntu"
private_key = file(var.ssh_private_key_file)
host = split("/", self.initialization[0].ip_config[0].ipv4[0].address)[0]
}
provisioner "remote-exec" {
inline = [
"sudo hostnamectl set-hostname ${self.name}",
"sudo systemctl restart avahi-daemon",
]
}
lifecycle {
ignore_changes = [
initialization[0].user_data_file_id,
]
}
}
resource "ansible_host" "jumper" {
name = "jumper.local"
groups = ["jumper", "portainer_agent"]
}
resource "proxmox_virtual_environment_vm" "bench" {
name = "bench"
description = "Managed by Terraform"
tags = ["terraform", "ubuntu", "hut"]
node_name = "pve"
vm_id = 20001
cpu {
cores = 1
type = "host"
}
memory {
dedicated = 1024
floating = 1024
}
agent {
enabled = true
}
startup {
order = "1"
up_delay = "60"
down_delay = "60"
}
disk {
datastore_id = var.proxmox_vm_storage
file_id = proxmox_virtual_environment_file.ubuntu_cloud_image.id
interface = "virtio0"
iothread = true
discard = "on"
size = 16
file_format = "qcow2"
}
initialization {
ip_config {
ipv4 {
address = "10.0.44.3/16"
gateway = var.gateway
}
}
datastore_id = var.proxmox_image_storage
user_data_file_id = proxmox_virtual_environment_file.common_cloud_init.id
}
network_device {
bridge = "vmbr0"
}
operating_system {
type = "l26"
}
connection {
type = "ssh"
user = "ubuntu"
private_key = file(var.ssh_private_key_file)
host = split("/", self.initialization[0].ip_config[0].ipv4[0].address)[0]
}
provisioner "remote-exec" {
inline = [
"sudo hostnamectl set-hostname ${self.name}",
"sudo systemctl restart avahi-daemon",
]
}
lifecycle {
ignore_changes = [
initialization[0].user_data_file_id,
]
}
}
# resource "proxmox_virtual_environment_vm" "press" {
# name = "press"
# description = "Managed by Terraform"
# tags = ["terraform", "ubuntu", "hut"]
# node_name = "pve"
# vm_id = 20002
# cpu {
# cores = 1
# type = "host"
# }
# memory {
# dedicated = 1024
# floating = 1024
# }
# agent {
# enabled = true
# }
# startup {
# order = "1"
# up_delay = "60"
# down_delay = "60"
# }
# disk {
# datastore_id = var.proxmox_vm_storage
# file_id = proxmox_virtual_environment_file.ubuntu_cloud_image.id
# interface = "virtio0"
# iothread = true
# discard = "on"
# size = 16
# file_format = "qcow2"
# }
# initialization {
# ip_config {
# ipv4 {
# address = "10.0.44.4/16"
# gateway = var.gateway
# }
# }
# datastore_id = var.proxmox_image_storage
# user_data_file_id = proxmox_virtual_environment_file.common_cloud_init.id
# }
# network_device {
# bridge = "vmbr0"
# }
# operating_system {
# type = "l26"
# }
# connection {
# type = "ssh"
# user = "ubuntu"
# private_key = file(var.ssh_private_key_file)
# host = split("/", self.initialization[0].ip_config[0].ipv4[0].address)[0]
# }
# provisioner "remote-exec" {
# inline = [
# "sudo hostnamectl set-hostname ${self.name}",
# "sudo systemctl restart avahi-daemon",
# ]
# }
# lifecycle {
# ignore_changes = [
# initialization[0].user_data_file_id,
# ]
# }
# }