diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index ad6b11a..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -stages: - - archive - -include: - - project: Lab/stuttgart-things/stuttgart-things - file: build/gitlab/tasks/archive-module-pipeline.yaml - ref: master diff --git a/provider.tf b/provider.tf index 8d3d5ad..783c650 100644 --- a/provider.tf +++ b/provider.tf @@ -1,7 +1,10 @@ terraform { + required_version = ">= 1.5.5" + required_providers { proxmox = { - source = "Telmate/proxmox" + source = "Telmate/proxmox" + version = ">= 2.9.14" } } } diff --git a/variables.tf b/variables.tf index 56ca19a..a25c4eb 100644 --- a/variables.tf +++ b/variables.tf @@ -1,124 +1,166 @@ variable "pve_cluster_node" { default = false + type = string description = "name of proxmox cluster node" } variable "pve_folder_path" { default = false + type = string description = "target (vm) folder path of proxmox virtual machine" } variable "pve_datastore" { default = false + type = string description = "name of proxmox datastore" } variable "pve_network" { default = false + type = string description = "name of proxmox network" } variable "vm_numa" { default = true + type = bool description = "enable numa for vm" } variable "vm_onboot" { default = true + type = bool description = "whether to have the VM startup after the PVE node starts" } variable "vm_firmware" { default = "seabios" + type = string description = "the firmware interface to use on the virtual machine. Can be one of bios or EFI. Default: bios" } variable "vm_os_type" { default = "l26" + type = string description = "the type of OS in the guest to allow Proxmox to enable optimizations for the appropriate guest OS" } variable "vm_count" { default = 1 + type = number description = "count of vms" + + validation { + condition = var.vm_count >= 1 && var.vm_count <= 5 && floor(var.vm_count) == var.vm_count + error_message = "Accepted values: 1-5." + } + } variable "vm_name" { - default = "terraform-vm" + default = false + type = string description = "name of proxmox virtual machine" } variable "vm_guest_agent" { default = 1 + type = number description = "QEMU Guest Agent configuration set 0 to disable 1 to enable" } variable "vm_notes" { default = false + type = string description = "notes of proxmox virtual machine shwon in UI" } variable "vm_template" { default = false + type = string description = "name of proxmox virtual machine template" } variable "vm_num_cpus" { default = 2 + type = number description = "amount of cpus of the vm" + + validation { + condition = contains([2, 4, 6, 8, 10, 12, 16], var.vm_num_cpus) + error_message = "Valid values for vm_num_cpus are (2, 4, 6, 8, 10, 12, 16)" + } + } variable "vm_num_sockets" { default = 1 + type = number description = "amount of sockets of the vm" } variable "vm_memory" { - default = 2048 + default = 4096 + type = number description = "amount of memory of the vm" } variable "vm_disk_size" { - default = "30G" + default = "32G" description = "size of disk" + + validation { + condition = contains(["20G", "32G", "64G", "96G", "128G", "196G", "256G"], var.vm_disk_size) + error_message = "Valid values for vm_disk_size are (20G, 32G, 64G, 96G, 128G, 196G, 256G)" + } + } variable "vm_disk_type" { default = "virtio" + type = string description = "type of disk" } variable "vm_bootdisk" { default = "virtio0" + type = string description = "default boot disk" } variable "vm_storage_controller" { default = "virtio-scsi-pci" + type = string description = "storage controller to emulate" } variable "vm_network_type" { default = "virtio" + type = string description = "network card type" } variable "vm_ssh_user" { default = "" + type = string description = "Username of VM" } variable "vm_ssh_password" { default = "" + type = string description = "Password of VM user" } variable "vm_network_address0" { default = "ip=dhcp" + type = string description = "The first IP address to assign to the guest (set to ip=dhcp to get a ip output)" } variable "vm_macaddr" { default = null + type = string description = "Mac address of desired vm" } diff --git a/vm.tf b/vm.tf index 85684d6..65126cf 100644 --- a/vm.tf +++ b/vm.tf @@ -16,25 +16,25 @@ resource "proxmox_vm_qemu" "proxmox_vm" { bootdisk = var.vm_bootdisk agent = var.vm_guest_agent qemu_os = var.vm_os_type - + disk { size = var.vm_disk_size type = var.vm_disk_type storage = var.pve_datastore } - + network { model = var.vm_network_type bridge = var.pve_network macaddr = var.vm_macaddr } - + lifecycle { ignore_changes = [ network, ] } - + connection { type = "ssh" host = self.default_ipv4_address