-
Notifications
You must be signed in to change notification settings - Fork 2
/
proxmox-vm.tf
63 lines (49 loc) · 1.96 KB
/
proxmox-vm.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
resource "proxmox_vm_qemu" "vm" {
for_each = {
for vm in var.proxmox_vms : vm.name => vm
}
# Node name has to be the same name as within the cluster
# this might not include the FQDN
target_node = coalesce(each.value.target_node, var.proxmox_defaults.target_node)
# The template name to clone this vm from
clone = coalesce(each.value.clone_override, var.proxmox_defaults.proxmox_clone)
full_clone = coalesce(each.value.full_clone, true)
vmid = coalesce(each.value.id, random_integer.vm-id.result)
name = each.value.name
## With preprovision, you can provision a VM directly from the resource block.
## This provisioning method is therefore ran ** before** provision blocks.
## When using preprovision, there are three os_type options: ubuntu, centos or cloud-init.
os_type = "cloud-init"
ciuser = coalesce(each.value.os, var.proxmox_defaults.os)
## Resource Configuration
cores = coalesce(each.value.cores, var.proxmox_defaults.cores)
sockets = coalesce(each.value.sockets, var.proxmox_defaults.sockets)
memory = coalesce(each.value.memory, var.proxmox_defaults.memory)
hotplug = coalesce(each.value.hotplug, var.proxmox_defaults.hotplug)
boot = "c"
sshkeys = coalesce(each.value.sshkeys, var.proxmox_ssh)
scsihw = coalesce(each.value.scsihw, "virtio-scsi-single")
# Setup the disk
dynamic "disk" {
for_each = coalesce(each.value.disk_configuration, var.proxmox_defaults.disk_configuration)
content {
size = each.value.size
type = each.value.type
storage = each.value.storage
}
}
dynamic "network" {
for_each = coalesce(each.value.network_configuration, var.proxmox_defaults.network_configuration)
content {
model = each.value.model
bridge = each.value.bridge
}
}
# Setup the ip address using cloud-init.
# Keep in mind to use the CIDR notation for the ip.
ipconfig0 = each.value.ipconfig
}
resource "random_integer" "vm-id" {
min = 90000
max = 100000
}