feat: Boot from imported image
This commit is contained in:
parent
7c234a73d1
commit
0e0b848d07
3 changed files with 36 additions and 17 deletions
|
|
@ -2,7 +2,7 @@ terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
proxmox = {
|
proxmox = {
|
||||||
source = "bpg/proxmox"
|
source = "bpg/proxmox"
|
||||||
version = "0.85.1"
|
version = "0.86.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,17 +18,28 @@ data "http" "schematic" {
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
schematic_id = jsondecode(data.http.schematic.response_body)["id"]
|
schematic_id = jsondecode(data.http.schematic.response_body)["id"]
|
||||||
iso_url = "${"https://factory.talos.dev/image"}/${local.schematic_id}/v${var.talos_version}/nocloud-amd64-secureboot.iso"
|
iso_url = "${"https://factory.talos.dev/image"}/${local.schematic_id}/v${var.talos_version}/nocloud-amd64-secureboot.raw.xz"
|
||||||
iso_file = "talos-${var.talos_version}-nocloud-amd64-secureboot.iso"
|
iso_file = "talos-${var.talos_version}-nocloud-amd64-secureboot.raw"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "proxmox_virtual_environment_download_file" "talos-image" {
|
resource "null_resource" "local_download_talos_image" {
|
||||||
|
provisioner "local-exec" {
|
||||||
|
command = <<EOT
|
||||||
|
curl -L ${local.iso_url} -o ${path.module}/${local.iso_file}.xz
|
||||||
|
xz -d ${path.module}/${local.iso_file}.xz
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "proxmox_virtual_environment_file" "talos-image" {
|
||||||
|
depends_on = [null_resource.local_download_talos_image]
|
||||||
|
|
||||||
node_name = "pve01"
|
node_name = "pve01"
|
||||||
content_type = "iso"
|
content_type = "import"
|
||||||
datastore_id = "local"
|
datastore_id = "local"
|
||||||
overwrite = true
|
overwrite = true
|
||||||
|
|
||||||
url = local.iso_url
|
source_file {
|
||||||
file_name = local.iso_file
|
path = "${path.module}/${local.iso_file}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
output "talos_image_id" {
|
||||||
|
description = "The ID of the Talos image"
|
||||||
|
value = proxmox_virtual_environment_file.talos-image.id
|
||||||
|
}
|
||||||
|
|
@ -37,13 +37,19 @@ resource "proxmox_virtual_environment_vm" "talos-node" {
|
||||||
disk {
|
disk {
|
||||||
datastore_id = var.node.storagepool
|
datastore_id = var.node.storagepool
|
||||||
interface = "virtio0"
|
interface = "virtio0"
|
||||||
aio = "io_uring"
|
import_from = var.talos_image_id
|
||||||
size = var.node.disk
|
size = var.node.disk
|
||||||
file_format = "raw"
|
file_format = "raw"
|
||||||
}
|
}
|
||||||
|
|
||||||
cdrom {
|
dynamic "disk" {
|
||||||
file_id = format("local:iso/talos-%s-nocloud-amd64-secureboot.iso", var.node.talos_version)
|
for_each = tolist(var.pvc_disks)
|
||||||
|
content {
|
||||||
|
datastore_id = "nvme-fastpool"
|
||||||
|
interface = "virtio${disk.key + 1}"
|
||||||
|
size = disk.value
|
||||||
|
file_format = "raw"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
efi_disk {
|
efi_disk {
|
||||||
|
|
@ -52,8 +58,6 @@ resource "proxmox_virtual_environment_vm" "talos-node" {
|
||||||
type = "4m"
|
type = "4m"
|
||||||
}
|
}
|
||||||
|
|
||||||
boot_order = ["virtio0", "ide3", "net0"]
|
|
||||||
|
|
||||||
tpm_state {
|
tpm_state {
|
||||||
datastore_id = var.node.storagepool
|
datastore_id = var.node.storagepool
|
||||||
version = "v2.0"
|
version = "v2.0"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue