This commit is contained in:
2026-02-01 14:37:19 +00:00
commit f9ec0b4202
7 changed files with 280 additions and 0 deletions

77
main.tf_org Normal file
View File

@@ -0,0 +1,77 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = ">= 0.60.0" # Empfohlene Version für OpenTofu
}
}
}
provider "proxmox" {
endpoint = var.pm_api_url
api_token = var.pm_api_token
insecure = var.pm_insecure
# SSH-Konfiguration hinzufügen
ssh {
agent = true # Nutzt deinen lokalen ssh-agent
username = "root" # Oder ein anderer User mit Root-Rechten auf dem PVE-Host
# Alternativ, falls kein Agent genutzt wird:
private_key = file("/home/braniz/.ssh/id_ed25519")
}
}
resource "proxmox_virtual_environment_vm" "proxmox_vm" {
name = var.pm_vm_name
description = "Erstellt mit OpenTofu"
node_name = var.pm_host
vm_id = var.pm_vm_id
# Erzwingt das Stoppen der VM vor dem Löschen (verhindert hängende Locks)
stop_on_destroy = true
cpu {
cores = 4
}
memory {
dedicated = 8192
}
# Erste Festplatte (20 GB)
disk {
datastore_id = "ceph-pool"
file_id = var.pm_cloud_image
size = 20
interface = "scsi0"
file_format = "raw"
}
# Zweite Festplatte (20 GB)
disk {
datastore_id = "ceph-pool"
size = 20
interface = "scsi1"
file_format = "raw"
}
initialization {
datastore_id = "ceph-pool"
user_account {
username = "braniz"
keys = ["ssh-ed25519 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBh9BFdBV7WrrlOLmNZEe8dXJEOVK2Vc3c/0jLiD27ZD root@iqprox01"]
}
# Aktiviert DHCP über Cloud-Init
ip_config {
ipv4 {
address = "dhcp"
}
}
}
network_device {
bridge = "vmbr0"
}
}