commit 7634f6f86c9fef9c67fb00e0d6fb7a60afe72111 Author: InAnYan Date: Wed Jul 29 16:47:06 2026 +0200 init: add initial code diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..2548c11 --- /dev/null +++ b/main.tf @@ -0,0 +1,51 @@ +terraform { + required_providers { + proxmox = { + source = "bpg/proxmox" + version = "~> 0.78.2" + } + } +} + +resource "proxmox_virtual_environment_vm" "this" { + name = var.vm_name + node_name = var.node_name + vm_id = var.vm_id + + clone { + vm_id = var.template_id + } + + agent { + enabled = true + } + + cpu { + cores = var.cpu_cores + type = "x86-64-v2-AES" + } + + memory { + dedicated = var.memory_mb + } + + network_device { + bridge = var.bridge + } + + initialization { + hostname = var.vm_name + + ip_config { + ipv4 { + address = var.ip_address + gateway = var.gateway + } + } + + user_account { + username = "debian" + keys = [var.ssh_public_key] + } + } +} \ No newline at end of file diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..a4b5e71 --- /dev/null +++ b/variables.tf @@ -0,0 +1,55 @@ +variable "vm_id" { + description = "Proxmox VM ID" + type = number +} + +variable "vm_name" { + description = "Name of the VM in Proxmox UI and internal OS hostname" + type = string +} + +variable "ip_address" { + description = "Static IPv4 address in CIDR format (e.g., 192.168.100.50/24)" + type = string +} + +variable "ssh_public_key" { + description = "Public SSH key for the admin user" + type = string +} + +variable "gateway" { + description = "Network gateway IP address" + type = string + default = "192.168.100.1" +} + +variable "node_name" { + description = "Proxmox node name" + type = string + default = "itlab-ffeks" +} + +variable "template_id" { + description = "ID of the VM template to clone" + type = number + default = 203 +} + +variable "cpu_cores" { + description = "Number of CPU cores" + type = number + default = 2 +} + +variable "memory_mb" { + description = "RAM size in MB" + type = number + default = 2048 +} + +variable "bridge" { + description = "Network bridge interface" + type = string + default = "vmbr1" +} \ No newline at end of file