Initial
This commit is contained in:
89
main.tf
Normal file
89
main.tf
Normal file
@@ -0,0 +1,89 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = ">= 0.60.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "proxmox" {
|
||||
endpoint = var.pm_api_url
|
||||
api_token = var.pm_api_token
|
||||
insecure = var.pm_insecure
|
||||
|
||||
ssh {
|
||||
agent = false # Auf false, da wir den Pfad direkt angeben
|
||||
username = "root"
|
||||
private_key = file("/home/braniz/.ssh/prox/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
|
||||
stop_on_destroy = true
|
||||
|
||||
agent {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
cpu {
|
||||
cores = 4
|
||||
type = "host" # 'host' sorgt für bessere Performance bei Ceph/KVM
|
||||
}
|
||||
|
||||
memory {
|
||||
dedicated = 8192
|
||||
}
|
||||
|
||||
# Erste Festplatte (OS) - Ceph RBD
|
||||
disk {
|
||||
datastore_id = "ceph-pool"
|
||||
file_id = var.pm_cloud_image
|
||||
interface = "scsi0"
|
||||
size = 20
|
||||
discard = "on" # Wichtig für Ceph, um Platz freizugeben (TRIM)
|
||||
}
|
||||
|
||||
# Zweite Festplatte (Daten)
|
||||
disk {
|
||||
datastore_id = "ceph-pool"
|
||||
interface = "scsi1"
|
||||
size = 20
|
||||
discard = "on"
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr0"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = "ceph-pool" # Konsistent zum Disk-Storage
|
||||
|
||||
user_account {
|
||||
username = "braniz"
|
||||
# Hier deinen vollständigen Key einfügen:
|
||||
keys = [var.pm_ssh_public_key]
|
||||
}
|
||||
|
||||
ip_config {
|
||||
ipv4 {
|
||||
address = "dhcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
output "vm_ip" {
|
||||
description = "Die IP der VM"
|
||||
# Wir nehmen das erste Element, das NICHT 127.0.0.1 ist
|
||||
value = try(
|
||||
[for ip in flatten(proxmox_virtual_environment_vm.proxmox_vm.ipv4_addresses) : ip if ip != "127.0.0.1"][0],
|
||||
"Wartet auf DHCP/Agent..."
|
||||
)
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user