Просмотр исходного кода

Merge pull request #694 from ChristianLempa/555-enhance-update-the-proxmox-terraform-files

Updated proxmox vm template
Christian Lempa 1 год назад
Родитель
Сommit
5aa52addb5

+ 0 - 3
terraform/proxmox/README.md

@@ -1,3 +0,0 @@
-# Terraform Proxmox
-
-You can add an additional description here.

+ 0 - 49
terraform/proxmox/full-clone.tf

@@ -1,49 +0,0 @@
-# Proxmox Full-Clone
-# ---
-# Create a new VM from a clone
-
-resource "proxmox_vm_qemu" "your-vm" {
-
-    # VM General Settings
-    target_node = "your-proxmox-node"
-    vmid = "100"
-    name = "vm-name"
-    desc = "Description"
-
-    # VM Advanced General Settings
-    onboot = true
-
-    # VM OS Settings
-    clone = "your-clone"
-
-    # VM System Settings
-    agent = 1
-
-    # VM CPU Settings
-    cores = 1
-    sockets = 1
-    cpu = "host"
-
-    # VM Memory Settings
-    memory = 1024
-
-    # VM Network Settings
-    network {
-        bridge = "vmbr0"
-        model  = "virtio"
-    }
-
-    # VM Cloud-Init Settings
-    os_type = "cloud-init"
-
-    # (Optional) IP Address and Gateway
-    # ipconfig0 = "ip=0.0.0.0/0,gw=0.0.0.0"
-
-    # (Optional) Default User
-    # ciuser = "your-username"
-
-    # (Optional) Add your SSH KEY
-    # sshkeys = <<EOF
-    # #YOUR-PUBLIC-SSH-KEY
-    # EOF
-}

+ 20 - 17
terraform/proxmox/provider.tf

@@ -3,36 +3,39 @@
 # Initial Provider Configuration for Proxmox
 
 terraform {
+  required_version = ">= 0.13.0"
 
-    required_version = ">= 0.13.0"
-
-    required_providers {
-        proxmox = {
-            source = "telmate/proxmox"
-            version = ">= 2.9.14"
-        }
+  required_providers {
+    proxmox = {
+      source = "telmate/proxmox"
+      version = "3.0.1-rc6"
     }
+  }
 }
 
 variable "proxmox_api_url" {
-    type = string
+  type = string
 }
 
 variable "proxmox_api_token_id" {
-    type = string
+  type = string
 }
 
 variable "proxmox_api_token_secret" {
-    type = string
+  type = string
 }
 
-provider "proxmox" {
-
-    pm_api_url = var.proxmox_api_url
-    pm_api_token_id = var.proxmox_api_token_id
-    pm_api_token_secret = var.proxmox_api_token_secret
+variable "PUBLIC_SSH_KEY" {
+  
+  # -- Public SSH Key, you want to upload to VMs and LXC containers.
 
-    # (Optional) Skip TLS Verification
-    # pm_tls_insecure = true
+  type = string
+  sensitive = true
+}
 
+provider "proxmox" {
+  pm_api_url = var.proxmox_api_url
+  pm_api_token_id = var.proxmox_api_token_id
+  pm_api_token_secret = var.proxmox_api_token_secret
+  pm_tls_insecure = false  # <-- (Optional) Change to true if you are using self-signed certificates
 }

+ 72 - 0
terraform/proxmox/vmqemu.tf

@@ -0,0 +1,72 @@
+resource "proxmox_vm_qemu" "your-vm" {
+  
+  # -- General settings
+
+  name = "vm-name"
+  desc = "description"
+  agent = 1  # <-- (Optional) Enable QEMU Guest Agent
+  target_node = "your-proxmox-node"  # <-- Change to the name of your Proxmox node (if you have multiple nodes)
+  tags = "your-tag-1,your-tag-2"
+  vmid = "100"
+
+  # -- Template settings
+
+  clone = "your-clone-name"  # <-- Change to the name of the template or VM you want to clone
+  full_clone = true  # <-- (Optional) Set to "false" to create a linked clone
+
+  # -- Boot Process
+
+  onboot = true 
+  startup = ""  # <-- (Optional) Change startup and shutdown behavior
+  automatic_reboot = false  # <-- Automatically reboot the VM after config change
+
+  # -- Hardware Settings
+
+  qemu_os = "other"
+  bios = "ovmf"
+  cores = 2
+  sockets = 1
+  cpu_type = "host"
+  memory = 2048
+  balloon = 2048  # <-- (Optional) Minimum memory of the balloon device, set to 0 to disable ballooning
+  
+
+  # -- Network Settings
+
+  network {
+    id     = 0  # <-- ! required since 3.x.x
+    bridge = "vmbr1"
+    model  = "virtio"
+  }
+
+  # -- Disk Settings
+  
+  scsihw = "virtio-scsi-single"  # <-- (Optional) Change the SCSI controller type, since Proxmox 7.3, virtio-scsi-single is the default one         
+  
+  disks {  # <-- ! changed in 3.x.x
+    ide {
+      ide0 {
+        cloudinit {
+          storage = "local-lvm"
+        }
+      }
+    }
+    virtio {
+      virtio0 {
+        disk {
+          storage = "local-lvm"
+          size = "20G"  # <-- Change the desired disk size, ! since 3.x.x size change will trigger a disk resize
+          iothread = true  # <-- (Optional) Enable IOThread for better disk performance in virtio-scsi-single
+          replicate = false  # <-- (Optional) Enable for disk replication
+        }
+      }
+    }
+  }
+
+  # -- Cloud Init Settings
+
+  ipconfig0 = "ip=0.0.0.0/0,gw=0.0.0.0"  # <-- Change to your desired IP configuration
+  nameserver = "0.0.0.0"  # <-- Change to your desired DNS server
+  ciuser = "your-username"
+  sshkeys = var.PUBLIC_SSH_KEY  # <-- (Optional) Change to your public SSH key
+}