-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlibvirt.tf
111 lines (106 loc) · 3.15 KB
/
libvirt.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
# see https://github.com/dmacvicar/terraform-provider-libvirt/blob/v0.8.1/website/docs/r/network.markdown
resource "libvirt_network" "talos" {
name = var.prefix
mode = "nat"
domain = var.cluster_node_domain
addresses = [var.cluster_node_network]
dhcp {
enabled = true
}
dns {
enabled = true
local_only = false
}
}
# see https://github.com/dmacvicar/terraform-provider-libvirt/blob/v0.8.1/website/docs/r/volume.html.markdown
resource "libvirt_volume" "controller" {
count = var.controller_count
name = "${var.prefix}_c${count.index}.img"
base_volume_name = var.talos_libvirt_base_volume_name
format = "qcow2"
size = 40 * 1024 * 1024 * 1024 # 40GiB.
}
# see https://github.com/dmacvicar/terraform-provider-libvirt/blob/v0.8.1/website/docs/r/volume.html.markdown
resource "libvirt_volume" "worker" {
count = var.worker_count
name = "${var.prefix}_w${count.index}.img"
base_volume_name = var.talos_libvirt_base_volume_name
format = "qcow2"
size = 40 * 1024 * 1024 * 1024 # 40GiB.
}
# see https://github.com/dmacvicar/terraform-provider-libvirt/blob/v0.8.1/website/docs/r/volume.html.markdown
resource "libvirt_volume" "worker_data0" {
count = var.worker_count
name = "${var.prefix}_w${count.index}d0.img"
format = "qcow2"
size = 32 * 1024 * 1024 * 1024 # 32GiB.
}
# see https://github.com/dmacvicar/terraform-provider-libvirt/blob/v0.8.1/website/docs/r/domain.html.markdown
resource "libvirt_domain" "controller" {
count = var.controller_count
name = "${var.prefix}_${local.controller_nodes[count.index].name}"
qemu_agent = false
machine = "q35"
firmware = "/usr/share/OVMF/OVMF_CODE.fd"
cpu {
mode = "host-passthrough"
}
vcpu = 4
memory = 4 * 1024
video {
type = "qxl"
}
disk {
volume_id = libvirt_volume.controller[count.index].id
scsi = true
}
network_interface {
network_id = libvirt_network.talos.id
addresses = [local.controller_nodes[count.index].address]
wait_for_lease = true
}
lifecycle {
ignore_changes = [
nvram,
disk[0].wwn,
network_interface[0].addresses,
]
}
}
# see https://github.com/dmacvicar/terraform-provider-libvirt/blob/v0.8.1/website/docs/r/domain.html.markdown
resource "libvirt_domain" "worker" {
count = var.worker_count
name = "${var.prefix}_${local.worker_nodes[count.index].name}"
qemu_agent = false
machine = "q35"
firmware = "/usr/share/OVMF/OVMF_CODE.fd"
cpu {
mode = "host-passthrough"
}
vcpu = 4
memory = 4 * 1024
video {
type = "qxl"
}
disk {
volume_id = libvirt_volume.worker[count.index].id
scsi = true
}
disk {
volume_id = libvirt_volume.worker_data0[count.index].id
scsi = true
wwn = format("000000000000ab%02x", count.index)
}
network_interface {
network_id = libvirt_network.talos.id
addresses = [local.worker_nodes[count.index].address]
wait_for_lease = true
}
lifecycle {
ignore_changes = [
nvram,
disk[0].wwn,
network_interface[0].addresses,
]
}
}