Repository navigation
Expand file tree
/
Copy pathnode.tf
More file actions
77 lines (63 loc) · 1.69 KB
/
Copy pathnode.tf
File metadata and controls
77 lines (63 loc) · 1.69 KB
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
resource "libvirt_volume" "node" {
count = var.node_count
name = "node${count.index+1}"
pool = libvirt_pool.base-pool.name
base_volume_id = libvirt_volume.base.id
format = "qcow2"
size = var.node_disk_size
}
resource "libvirt_volume" "data" {
count = var.node_count
name = "data${count.index+1}"
pool = "default"
format = "qcow2"
size = var.data_disk_size
}
resource "libvirt_cloudinit_disk" "nodeinit" {
count = var.node_count
name = "nodeinit${count.index+1}"
pool = libvirt_pool.base-pool.name
user_data = data.template_file.node_data[count.index].rendered
network_config = data.template_file.node_network[count.index].rendered
}
resource "libvirt_domain" "node" {
count = var.node_count
name = "node${count.index+1}"
memory = var.node_memory
vcpu = var.node_cpus
autostart = "true"
qemu_agent = "true"
network_interface {
wait_for_lease = true
bridge = var.bridge
mac = "AA:BB:CC:11:22:0${count.index+1}"
}
boot_device {
dev = ["hd", "network"]
}
console {
type = "pty"
target_type = "serial"
target_port = "0"
}
disk {
volume_id = element(libvirt_volume.node.*.id, count.index)
}
disk {
volume_id = element(libvirt_volume.data.*.id, count.index)
}
cloudinit = element(libvirt_cloudinit_disk.nodeinit.*.id, count.index)
graphics {
type = "vnc"
listen_type = "address"
autoport = true
}
}
output "node_hostname" {
value = "${libvirt_domain.node.*.network_interface.0.hostname}"
description = "The hostname of the node server instance"
}
output "node_ip" {
value = "${libvirt_domain.node.*.network_interface.0.addresses}"
description = "The IP address of the node server instance"
}