This commit is contained in:
Hrankin, Aleksandr (contracted)
2026-02-19 11:34:13 +00:00
commit f243f440c3
191 changed files with 6183 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
resource "proxmox_virtual_environment_vm" "this" {
name = var.name
node_name = var.target_node
clone {
vm_id = var.template_id
full = true
}
cpu {
cores = var.cpu
type = var.cpu_type
}
memory {
dedicated = var.memory
}
# Предсказуемая SCSI нумерация
scsi_hardware = "virtio-scsi-single"
boot_order = ["scsi0"]
# OS disk (scsi0)
disk {
datastore_id = var.storage
size = var.disk_size
interface = "scsi0"
}
# OSD disks (scsi1, scsi2, ...)
dynamic "disk" {
for_each = (var.osd_storage != null && length(var.osd_disks) > 0) ? { for idx, size in var.osd_disks : idx => size } : {}
content {
datastore_id = var.osd_storage
size = disk.value
interface = "scsi${disk.key + 1}"
file_format = "raw"
cache = "none"
iothread = true
discard = "on"
}
}
network_device {
bridge = var.bridge
model = "virtio"
mac_address = var.mac_address
}
agent {
enabled = true
}
initialization {
user_data_file_id = var.user_data_file_id
ip_config {
ipv4 { address = "dhcp" }
}
}
}

View File

@@ -0,0 +1,55 @@
variable "name" {
type = string
}
variable "target_node" {
type = string
}
variable "template_id" {
type = number
}
variable "cpu" {
type = number
}
variable "cpu_type" {
type = string
}
variable "memory" {
type = number
}
variable "disk_size" {
type = number
}
variable "storage" {
type = string
}
variable "bridge" {
type = string
}
variable "osd_storage" {
type = string
default = null
}
variable "osd_disks" {
type = list(number)
default = []
}
variable "user_data_file_id" {
type = string
default = null
}
variable "mac_address" {
description = "Static MAC for VM NIC (for DHCP reservation)."
type = string
}

View File

@@ -0,0 +1,8 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = ">= 0.86.0"
}
}
}