chore: Refactor talos image creation
This commit is contained in:
parent
de4faf86ca
commit
1a791f6c37
3 changed files with 27 additions and 48 deletions
|
|
@ -1,8 +1,13 @@
|
|||
provider "proxmox" {
|
||||
endpoint = var.proxmox_endpoint
|
||||
api_token = var.proxmox_api_token
|
||||
ssh {
|
||||
agent = true
|
||||
username = "root"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
locals {
|
||||
talos_versions = ["1.11.5"]
|
||||
}
|
||||
|
|
@ -22,43 +27,31 @@ locals {
|
|||
storagepool = "nvme-fastpool"
|
||||
}
|
||||
|
||||
resource "null_resource" "local_download_talos_image" {
|
||||
resource "proxmox_virtual_environment_download_file" "talos-image" {
|
||||
for_each = toset(local.talos_versions)
|
||||
|
||||
provisioner "local-exec" {
|
||||
command = <<EOT
|
||||
curl -L https://factory.talos.dev/image/${local.schematic_id}/v${each.value}/nocloud-amd64-secureboot.raw.xz -o ${path.module}/talos-${each.value}-nocloud-amd64-secureboot.raw.xz
|
||||
xz -d ${path.module}/talos-${each.value}-nocloud-amd64-secureboot.raw.xz
|
||||
EOT
|
||||
}
|
||||
}
|
||||
node_name = "pve01"
|
||||
datastore_id = "local"
|
||||
content_type = "iso"
|
||||
|
||||
resource "proxmox_virtual_environment_file" "talos-image" {
|
||||
depends_on = [null_resource.local_download_talos_image]
|
||||
for_each = toset(local.talos_versions)
|
||||
|
||||
node_name = "pve01"
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
overwrite = true
|
||||
|
||||
source_file {
|
||||
path = "${path.module}/talos-${each.value}-nocloud-amd64-secureboot.raw"
|
||||
}
|
||||
url = "https://factory.talos.dev/image/${local.schematic_id}/v${each.value}/nocloud-amd64-secureboot.raw.gz"
|
||||
file_name = "talos-${each.value}-nocloud-amd64-secureboot.img"
|
||||
decompression_algorithm = "gz"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_vm" "talos-template" {
|
||||
depends_on = [proxmox_virtual_environment_file.talos-image]
|
||||
for_each = toset(local.talos_versions)
|
||||
depends_on = [proxmox_virtual_environment_download_file.talos-image]
|
||||
for_each = toset(local.talos_versions)
|
||||
|
||||
template = true
|
||||
vm_id = 10000 + tonumber(replace(each.value, ".", ""))
|
||||
name = "talos-template-${each.value}"
|
||||
node_name = "pve01"
|
||||
tags = ["tofu"]
|
||||
bios = "ovmf"
|
||||
on_boot = true
|
||||
machine = "q35"
|
||||
template = true
|
||||
vm_id = 10000 + tonumber(replace(each.value, ".", ""))
|
||||
name = "talos-template-${each.value}"
|
||||
node_name = "pve01"
|
||||
tags = ["tofu"]
|
||||
bios = "ovmf"
|
||||
on_boot = true
|
||||
machine = "q35"
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
|
|
@ -76,8 +69,7 @@ resource "proxmox_virtual_environment_vm" "talos-template" {
|
|||
disk {
|
||||
datastore_id = local.storagepool
|
||||
interface = "virtio0"
|
||||
import_from = proxmox_virtual_environment_file.talos-image[each.value].id
|
||||
size = 10
|
||||
file_id = proxmox_virtual_environment_download_file.talos-image[each.value].id
|
||||
file_format = "raw"
|
||||
}
|
||||
efi_disk {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue