Skip to content

Commit

Permalink
updated vars
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-hermann-sva committed Jan 22, 2024
1 parent d8806a3 commit f1eb18c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 16 deletions.
8 changes: 0 additions & 8 deletions .gitlab-ci.yml

This file was deleted.

5 changes: 4 additions & 1 deletion provider.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
terraform {
required_version = ">= 1.5.5"

required_providers {
proxmox = {
source = "Telmate/proxmox"
source = "Telmate/proxmox"
version = ">= 2.9.14"
}
}
}
48 changes: 45 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -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"
}
8 changes: 4 additions & 4 deletions vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f1eb18c

Please sign in to comment.