forked from sparrow-bork/terraform-proxmox-vm-nocloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
87 lines (74 loc) · 2 KB
/
main.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
resource "proxmox_cloud_init_disk" "this" {
count = var.vm_count
name = "${var.name}-${count.index}"
pve_node = var.target_node
storage = var.storage_name
meta_data = yamlencode({
instance_id = sha1("${var.name}-${count.index}")
local-hostname = "${var.name}-${count.index}"
})
user_data = var.user_data
network_config = yamlencode({
version = 1
config = [{
type = "physical"
name = "eth0"
subnets = [{
type = "static"
address = "${cidrhost("${var.network.ip_subnet}/${var.network.ip_prefix}", 200 + var.skip_vm_id + count.index)}/${var.network.ip_prefix}" # "${cidrhost(var.network.ip_cidr, 200 + count.index)}/24"
gateway = var.network.ip_gateway
dns_nameservers = var.network.dns_nameservers
}]
}]
})
}
resource "proxmox_vm_qemu" "this" {
count = var.vm_count
name = "${var.name}-${count.index}"
desc = <<-EOF
${var.name} VM
Talos Linux Kubernetes Cluster
EOF
vmid = 5000 + var.skip_vm_id + count.index
target_node = var.target_node
onboot = var.vm_onboot
vm_state = var.vm_state
protection = var.vm_protection
cpu = "x86-64-v2-AES"
cores = var.resource_allocation.cores
vcpus = var.resource_allocation.vcpus
sockets = var.resource_allocation.sockets
memory = var.resource_allocation.memory
scsihw = "virtio-scsi-single"
os_type = "cloud-init" # cloud-init, # ubuntu, # centos
disks {
ide {
ide2 {
cdrom {
iso = var.bootable_iso
}
}
}
scsi {
scsi0 {
cdrom {
iso = proxmox_cloud_init_disk.this[count.index].id
}
}
scsi1 {
disk {
emulatessd = false
format = "qcow2"
iothread = true
replicate = true
size = "${var.resource_allocation.storage}G"
storage = var.storage_name
}
}
}
}
network {
model = "virtio"
bridge = "vmbr0"
}
}