-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvirtual_machines.tf
114 lines (99 loc) · 2.64 KB
/
virtual_machines.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
resource "proxmox_virtual_environment_vm" "talos_cp" {
count = length(var.talos_control_planes)
name = var.talos_control_planes[count.index].proxmox_vm_name
vm_id = var.talos_control_planes[count.index].proxmox_vm_id
description = "Managed by Terraform"
tags = ["terraform"]
node_name = var.talos_control_planes[count.index].proxmox_node_name
on_boot = true
cpu {
cores = 2
type = "x86-64-v2-AES"
}
memory {
dedicated = 4096
}
agent {
enabled = true
}
network_device {
bridge = "vmbr0"
vlan_id = "30"
}
disk {
datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_download_file.talos_nocloud_image[index(proxmox_virtual_environment_download_file.talos_nocloud_image.*.node_name, var.talos_control_planes[count.index].proxmox_node_name)].id
file_format = "raw"
interface = "virtio0"
size = 20
}
operating_system {
type = "l26" # Linux Kernel 2.6 - 5.X.
}
initialization {
datastore_id = "local-lvm"
ip_config {
ipv4 {
address = "${var.talos_control_planes[count.index].ip}/24"
gateway = var.default_gateway
}
ipv6 {
address = "dhcp"
}
}
dns {
domain = var.dns_domain
servers = [var.dns_server]
}
}
}
resource "proxmox_virtual_environment_vm" "talos_worker" {
count = length(var.talos_workers)
depends_on = [proxmox_virtual_environment_vm.talos_cp]
name = var.talos_workers[count.index].proxmox_vm_name
vm_id = var.talos_workers[count.index].proxmox_vm_id
description = "Managed by Terraform"
tags = ["terraform"]
node_name = var.talos_workers[count.index].proxmox_node_name
on_boot = true
cpu {
cores = 4
type = "x86-64-v2-AES"
}
memory {
dedicated = 8192
}
agent {
enabled = true
}
network_device {
bridge = "vmbr0"
vlan_id = "30"
}
disk {
datastore_id = "local-lvm"
file_id = proxmox_virtual_environment_download_file.talos_nocloud_image[index(proxmox_virtual_environment_download_file.talos_nocloud_image.*.node_name, var.talos_workers[count.index].proxmox_node_name)].id
file_format = "raw"
interface = "virtio0"
size = 20
}
operating_system {
type = "l26" # Linux Kernel 2.6 - 5.X.
}
initialization {
datastore_id = "local-lvm"
ip_config {
ipv4 {
address = "${var.talos_workers[count.index].ip}/24"
gateway = var.default_gateway
}
ipv6 {
address = "dhcp"
}
}
dns {
domain = var.dns_domain
servers = [var.dns_server]
}
}
}