proxmox template

This commit is contained in:
Tomás Limpinho
2025-08-20 15:39:28 +01:00
parent 700e77907d
commit 79f2c04501
3 changed files with 77 additions and 55 deletions

View File

@ -11,10 +11,10 @@ terraform {
bitwarden = { bitwarden = {
source = "maxlaverse/bitwarden" source = "maxlaverse/bitwarden"
version = ">= 0.15.0" version = ">= 0.15.0"
} }
proxmox = { proxmox = {
source = "telmate/proxmox" source = "bpg/proxmox"
version = "3.0.1-rc9" version = "0.82.1"
} }
} }
backend "consul" { backend "consul" {

View File

@ -1,54 +1,70 @@
provider "proxmox" {
pm_api_url = var.proxmox_server
}
resource "proxmox_pool" "resource-pool" {
poolid = "resource-pool"
comment = "pool auto created"
}
resource "proxmox_vm_qemu" "vm-kubernetes-01" {
name = "VM-kubernetes-01"
target_node = "fenix"
vmid = 1001
desc = "VM kubernetes 01 created via iac"
bios = "seabios"
onboot = true
vm_state = "running"
boot = "order=scsi0;ide2;net0"
agent = 1
memory = 4096
hotplug = "network,disk,usb"
scsihw = "virtio-scsi-single"
pool = "resource-pool"
tags = "iac-tag"
os_type = "ubuntu"
ipconfig0 = "ip=192.168.1.24/24"
cpu {
cores = 2
sockets = 1
type = "x86-64-v2-AES"
}
network {
id = 0
model = "virtio"
bridge = "vmbr0"
}
disks {
ide { provider "proxmox" {
ide2 { endpoint = var.proxmox_server
cdrom { api_token = var.proxmox_apikey
iso = "local:iso/Fedora-Workstation-Live-x86_64-41-1.4.iso" }
}
} resource "proxmox_virtual_environment_download_file" "Fedora-iso" {
} content_type = "iso" # tipo do arquivo
scsi { datastore_id = "local" # datastore do Proxmox onde o arquivo será guardado
scsi0 { node_name = "fenix" # nó do Proxmox onde será armazenado
disk {
backup = true url = "https://download.fedoraproject.org/pub/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-41-1.4.iso"
size = "64G" }
storage = "local-lvm"
} resource "proxmox_virtual_environment_vm" "proxmox-kubernetes-VM-template" {
} name = "proxmox-kubernetes-VM-template"
} node_name = "fenix"
vm_id = 1002
template = true
started = false
tags = ["opentofu", "kubernetes", "fedora"]
machine = "q35"
bios = "seabios"
description = "kubernetes VM Template created via iac"
cpu {
cores = 2
} }
}
memory {
dedicated = 2048
}
# Configuração do disco rígido
disk {
datastore_id = "local-lvm"
interface = "scsi0"
size = 64
}
# Configuração da interface de rede
network_device {
bridge = "vmbr0"
model = "virtio"
}
# Configuração do CD-ROM com a ISO
cdrom {
enabled = true
file_id = "local:iso/Fedora-Workstation-Live-x86_64-41-1.4.iso"
}
initialization {
ip_config {
ipv4 {
address = "dhcp"
}
}
}
}

View File

@ -3,3 +3,9 @@ variable "proxmox_server" {
type = string type = string
sensitive = false sensitive = false
} }
variable "proxmox_apikey" {
description = "Proxmox server api key"
type = string
sensitive = false
}