forked from sparrow-bork/terraform-proxmox-vm-nocloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
125 lines (111 loc) · 3.16 KB
/
variables.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
variable "name" {
description = "The suffix to use for the cloud-init and VM"
type = string
}
variable "target_node" {
description = "The target node to deploy to"
type = string
default = "pve"
}
variable "storage_name" {
description = "The storage to deploy to"
type = string
default = "ssd"
}
variable "user_data" {
description = "The user-data config to supply for cloud-init"
type = string
default = ""
}
variable "vm_onboot" {
description = "Whether to have the VM startup after PVE node starts"
type = bool
default = false
}
variable "vm_state" {
description = "The state of the VM after creation"
type = string
default = "running"
validation {
condition = contains(["running", "stopped", "started"], var.vm_state)
error_message = "Valid values for var: vm_state are (running, stopped, started)."
}
}
variable "vm_protection" {
description = "Enable/disable the VM protection from being removed"
type = bool
default = false
}
variable "vm_count" {
description = "Number of VMs to create"
type = number
default = 1
validation {
condition = var.vm_count > 0
error_message = "Variable vm_count cannot be less than 1."
}
}
variable "resource_allocation" {
description = "The resource amount to allocation for CPU, Memory, and Storage"
type = object({
cores = optional(number, 1)
vcpus = optional(number, 1)
sockets = optional(number, 1)
memory = optional(number, 256)
storage = optional(string, 128)
})
default = {
cores = 1
vcpus = 1
sockets = 1
memory = 256
storage = 128
}
validation {
condition = var.resource_allocation.cores >= var.resource_allocation.vcpus
error_message = "CPU cores cannot be lesser than VCPUs."
}
validation {
condition = var.resource_allocation.cores > 0
error_message = "CPU cores cannot be less than 1"
}
validation {
condition = var.resource_allocation.vcpus > 0
error_message = "VCPUs cannot be less than 1"
}
validation {
condition = var.resource_allocation.sockets > 0
error_message = "CPU socket cannot be less than 1"
}
validation {
condition = var.resource_allocation.memory > 0
error_message = "Memory cannot be less than 1GB"
}
validation {
condition = var.resource_allocation.storage > 0
error_message = "Storage cannot be less than 1GB"
}
}
variable "network" {
description = "The network configuration for ip cidr, hostnum, gateway, and dns nameserver"
type = object({
ip_subnet = optional(string, "10.255.0.0")
ip_hostnum = optional(number, 200)
ip_prefix = optional(number, 24)
ip_gateway = string
dns_nameservers = optional(list(string), ["1.1.1.1", "8.8.8.8"])
})
}
variable "bootable_iso" {
description = "The ISO file name to boot from"
type = string
}
variable "skip_vm_id" {
description = "The number to increment for VM ids"
type = number
default = 0
validation {
condition = var.skip_vm_id >= 0
error_message = "Variable skip_vm_id cannot be less than 0."
}
}