update proxmox provider, fixes

This commit is contained in:
c0depool
2025-06-24 21:42:49 +01:00
parent 6416eeb633
commit 93baecb322
13 changed files with 183 additions and 160 deletions

2
.gitignore vendored
View File

@@ -10,6 +10,8 @@ bin
.private/
.logs/
.task/
# Packer
secrets.pkvars.hcl
# Terraform
.terraform*
terraform.tfstate*

View File

@@ -14,8 +14,11 @@ source "proxmox-iso" "talos" {
node = var.proxmox_node
insecure_skip_tls_verify = true
iso_file = "${var.base_iso_file}"
unmount_iso = true
boot_iso {
type = "scsi"
iso_file = "${var.base_iso_file}"
unmount = true
}
scsi_controller = "virtio-scsi-single"
network_adapters {
@@ -23,22 +26,22 @@ source "proxmox-iso" "talos" {
model = "virtio"
}
disks {
type = "scsi"
storage_pool = var.proxmox_storage
format = "raw"
disk_size = "1500M"
io_thread = true
cache_mode = "writethrough"
type = "scsi"
storage_pool = var.proxmox_storage
format = "raw"
disk_size = "2500M"
io_thread = true
cache_mode = "writethrough"
}
memory = 2048
vm_id = "9700"
cores = var.cores
cpu_type = var.cpu_type
sockets = "1"
ssh_username = "root"
ssh_password = "packer"
ssh_timeout = "15m"
memory = 2048
vm_id = "${var.vm_id}"
cores = var.cores
cpu_type = var.cpu_type
sockets = "1"
ssh_username = "root"
ssh_password = "packer"
ssh_timeout = "15m"
cloud_init = true
cloud_init_storage_pool = var.cloudinit_storage_pool

View File

@@ -33,15 +33,20 @@ variable "cloudinit_storage_pool" {
default = "local-lvm"
}
variable "vm_id" {
type = string
default = "9700"
}
variable "talos_version" {
type = string
default = "v1.6.7"
}
variable "base_iso_file" {
type = string
type = string
}
locals {
image = "https://github.com/talos-systems/talos/releases/download/${var.talos_version}/nocloud-amd64.raw.xz"
image = "https://factory.talos.dev/image/613e1592b2da41ae5e265e8789429f22e121aab91cb4deb6bc3c0b6262961245/${var.talos_version}/nocloud-amd64.raw.xz"
}

View File

@@ -1,9 +1,5 @@
proxmox_api_url = "https://<proxmox_ip>:8006/api2/json" # Your Proxmox IP Address
proxmox_node = "<proxmox_nodename>"
proxmox_api_token_id = "" # API Token ID
proxmox_api_token_secret = "" # API Token
proxmox_storage = "local-lvm"
vm_id = 9702
cpu_type = "host"
talos_version = "v1.7.1"
talos_version = "v1.10.4"
base_iso_file = "local:iso/archlinux-2024.06.01-x86_64.iso"

View File

@@ -0,0 +1,4 @@
proxmox_api_url = "https://<proxmox_ip>:8006/api2/json" # Your Proxmox IP Address
proxmox_node = "<proxmox_nodename>"
proxmox_api_token_id = "" # API Token ID
proxmox_api_token_secret = "" # API Token

View File

@@ -2,59 +2,68 @@
resource "proxmox_vm_qemu" "c0depool-talos" {
# Dynamic provisioning of multiple nodes
count = length(var.nodes)
# Dynamic provisioning of multiple nodes
count = length(var.nodes)
# VM General Settings
target_node = var.proxmox_node
name = var.nodes[count.index].node_name
vmid = var.nodes[count.index].vm_id
# VM General Settings
target_node = var.proxmox_node
name = var.nodes[count.index].node_name
vmid = var.nodes[count.index].vm_id
# VM Advanced General Settings
onboot = true
# VM Advanced General Settings
onboot = true
# VM OS Settings
clone = var.nodes[count.index].clone_target
# VM OS Settings
clone = var.nodes[count.index].clone_target
# VM System Settings
agent = 0
# VM CPU Settings
cores = var.nodes[count.index].node_cpu_cores
# VM System Settings
agent = 0
# VM CPU Settings
cpu {
cores = var.nodes[count.index].node_cpu_cores
sockets = 1
cpu = "host"
# VM Memory Settings
memory = var.nodes[count.index].node_memory
type = "host"
# VM Network Settings
network {
bridge = "vmbr0"
model = "virtio"
}
}
# VM Disk Settings
scsihw = "virtio-scsi-single"
disks {
scsi {
scsi0 {
disk {
size = var.nodes[count.index].node_disk
format = "raw"
iothread = true
backup = false
storage = "local-lvm"
}
}
# VM Memory Settings
memory = var.nodes[count.index].node_memory
# VM Network Settings
network {
id = 0
bridge = "vmbr0"
model = "virtio"
}
# VM Disk Settings
scsihw = "virtio-scsi-single"
disks {
scsi {
scsi0 {
disk {
size = var.nodes[count.index].node_disk
format = "raw"
iothread = true
backup = false
storage = "local-lvm"
}
}
scsi1 {
cloudinit {
storage = "local-lvm"
}
}
}
}
# VM Cloud-Init Settings
os_type = "cloud-init"
cloudinit_cdrom_storage = "local-lvm"
ipconfig0 = var.nodes[count.index].node_ipconfig
# VM Cloud-Init Settings
os_type = "cloud-init"
ipconfig0 = var.nodes[count.index].node_ipconfig
}
output "mac_addrs" {
value = [for value in proxmox_vm_qemu.c0depool-talos : lower(tostring(value.network[0].macaddr))]
value = [for value in proxmox_vm_qemu.c0depool-talos : lower(tostring(value.network[0].macaddr))]
}

View File

@@ -1,23 +1,20 @@
# Initial Provider Configuration for Proxmox
terraform {
required_version = ">= 0.13.0"
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "3.0.1-rc1"
}
required_providers {
proxmox = {
source = "Telmate/proxmox"
version = "3.0.2-rc01"
}
}
}
provider "proxmox" {
pm_api_url = var.proxmox_api_url
pm_api_token_id = var.proxmox_api_token_id
pm_api_token_secret = var.proxmox_api_token_secret
pm_tls_insecure = true
pm_api_url = var.proxmox_api_url
pm_api_token_id = var.proxmox_api_token_id
pm_api_token_secret = var.proxmox_api_token_secret
pm_tls_insecure = true
}

View File

@@ -2,68 +2,77 @@
resource "proxmox_vm_qemu" "c0depool-talos" {
# Dynamic provisioning of multiple nodes
count = length(var.nodes)
# Dynamic provisioning of multiple nodes
count = length(var.nodes)
# VM General Settings
target_node = var.proxmox_node
name = var.nodes[count.index].node_name
vmid = var.nodes[count.index].vm_id
# VM General Settings
target_node = var.proxmox_node
name = var.nodes[count.index].node_name
vmid = var.nodes[count.index].vm_id
# VM Advanced General Settings
onboot = true
# VM Advanced General Settings
onboot = true
# VM OS Settings
clone = var.nodes[count.index].clone_target
# VM OS Settings
clone = var.nodes[count.index].clone_target
# VM System Settings
agent = 0
# VM CPU Settings
cores = var.nodes[count.index].node_cpu_cores
# VM System Settings
agent = 0
# VM CPU Settings
cpu {
cores = var.nodes[count.index].node_cpu_cores
sockets = 1
cpu = "host"
# VM Memory Settings
memory = var.nodes[count.index].node_memory
type = "host"
# VM Network Settings
network {
bridge = "vmbr0"
model = "virtio"
}
}
# VM Disk Settings
scsihw = "virtio-scsi-single"
disks {
scsi {
scsi0 {
disk {
size = var.nodes[count.index].node_disk
format = "raw"
iothread = true
backup = false
storage = "local-lvm"
}
}
scsi1 {
disk {
size = var.nodes[count.index].additional_node_disk
format = "raw"
iothread = true
backup = false
storage = "local-lvm"
}
}
# VM Memory Settings
memory = var.nodes[count.index].node_memory
# VM Network Settings
network {
id = 0
bridge = "vmbr0"
model = "virtio"
}
# VM Disk Settings
scsihw = "virtio-scsi-single"
disks {
scsi {
scsi0 {
disk {
size = var.nodes[count.index].node_disk
format = "raw"
iothread = true
backup = false
storage = "local-lvm"
}
}
scsi1 {
disk {
size = var.nodes[count.index].additional_node_disk
format = "raw"
iothread = true
backup = false
storage = "local-lvm"
}
}
scsi2 {
cloudinit {
storage = "local-lvm"
}
}
}
}
# VM Cloud-Init Settings
os_type = "cloud-init"
cloudinit_cdrom_storage = "local-lvm"
ipconfig0 = var.nodes[count.index].node_ipconfig
# VM Cloud-Init Settings
os_type = "cloud-init"
ipconfig0 = var.nodes[count.index].node_ipconfig
}
output "mac_addrs" {
value = [for value in proxmox_vm_qemu.c0depool-talos : lower(tostring(value.network[0].macaddr))]
value = [for value in proxmox_vm_qemu.c0depool-talos : lower(tostring(value.network[0].macaddr))]
}

View File

@@ -1,23 +1,20 @@
# Initial Provider Configuration for Proxmox
terraform {
required_version = ">= 0.13.0"
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "3.0.1-rc1"
}
required_providers {
proxmox = {
source = "Telmate/proxmox"
version = "3.0.2-rc01"
}
}
}
provider "proxmox" {
pm_api_url = var.proxmox_api_url
pm_api_token_id = var.proxmox_api_token_id
pm_api_token_secret = var.proxmox_api_token_secret
pm_tls_insecure = true
pm_api_url = var.proxmox_api_url
pm_api_token_id = var.proxmox_api_token_id
pm_api_token_secret = var.proxmox_api_token_secret
pm_tls_insecure = true
}

View File

@@ -1,5 +0,0 @@
# Update the credentails and save this as credentials.auto.tfvars
proxmox_api_url = "https://<proxmox_ip>:8006/api2/json" # Your Proxmox IP Address
proxmox_node = "<proxmox_nodename>"
proxmox_api_token_id = "" # API Token ID
proxmox_api_token_secret = "" # API Token

View File

@@ -4,27 +4,27 @@ locals {
"0" = {
vm_id = 200
node_name = "talos-master-00"
clone_target = "talos-v1.7.1-cloud-init-template"
clone_target = var.clone_target
node_cpu_cores = "2"
node_memory = 2048
node_memory = 2560
node_ipconfig = "ip=192.168.0.170/24,gw=192.168.0.1"
node_disk = "32" # in GB
}
"1" = {
vm_id = 201
node_name = "talos-master-01"
clone_target = "talos-v1.7.1-cloud-init-template"
clone_target = var.clone_target
node_cpu_cores = "2"
node_memory = 2048
node_memory = 2560
node_ipconfig = "ip=192.168.0.171/24,gw=192.168.0.1"
node_disk = "32" # in GB
}
"2" = {
vm_id = 202
node_name = "talos-master-02"
clone_target = "talos-v1.7.1-cloud-init-template"
clone_target = var.clone_target
node_cpu_cores = "2"
node_memory = 2048
node_memory = 2560
node_ipconfig = "ip=192.168.0.172/24,gw=192.168.0.1"
node_disk = "32" # in GB
}
@@ -34,9 +34,9 @@ locals {
"0" = {
vm_id = 300
node_name = "talos-worker-00"
clone_target = "talos-v1.7.1-cloud-init-template"
clone_target = var.clone_target
node_cpu_cores = "4"
node_memory = 6144
node_memory = 7168
node_ipconfig = "ip=192.168.0.180/24,gw=192.168.0.1"
node_disk = "32"
additional_node_disk = "128" # for longhorn
@@ -44,9 +44,9 @@ locals {
"1" = {
vm_id = 301
node_name = "talos-worker-01"
clone_target = "talos-v1.7.1-cloud-init-template"
clone_target = var.clone_target
node_cpu_cores = "4"
node_memory = 6144
node_memory = 7168
node_ipconfig = "ip=192.168.0.181/24,gw=192.168.0.1"
node_disk = "32"
additional_node_disk = "128" # for longhorn
@@ -54,9 +54,9 @@ locals {
"2" = {
vm_id = 302
node_name = "talos-worker-02"
clone_target = "talos-v1.7.1-cloud-init-template"
clone_target = var.clone_target
node_cpu_cores = "4"
node_memory = 6144
node_memory = 7168
node_ipconfig = "ip=192.168.0.182/24,gw=192.168.0.1"
node_disk = "32"
additional_node_disk = "128" # for longhorn

View File

@@ -0,0 +1 @@
clone_target = "talos-v1.10.4-cloud-init-template"

View File

@@ -12,4 +12,9 @@ variable "proxmox_api_token_secret" {
variable "proxmox_node" {
type = string
}
variable "clone_target" {
type = string
default = "talos-v1.7.1-cloud-init-template"
}