-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
67 lines (64 loc) · 1.94 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
data "libvirt_network_dns_srv_template" "etcd" {
count = var.masters_count
service = "etcd-server-ssl"
protocol = "tcp"
domain = var.dns_domain
target = "etcd-${count.index}.${var.dns_domain}"
port = 2380
weight = 10
priority = 0
}
data "libvirt_network_dns_host_template" "host-aliases" {
count = var.masters_count
ip = var.hosts_info.masters[count.index].ip-address
hostname = "etcd-${count.index}.${var.dns_domain}"
}
resource "libvirt_network" "openshift" {
name = var.network_name
bridge = var.network_bridge
mode = "nat"
domain = var.dns_domain
addresses = [ var.cidr_address ]
dns {
enabled = true
local_only = true
dynamic srvs {
for_each = data.libvirt_network_dns_srv_template.etcd.*.rendered
content {
service = srvs.value["service"]
protocol = srvs.value["protocol"]
domain = srvs.value["domain"]
target = srvs.value["target"]
port = srvs.value["port"]
weight = srvs.value["weight"]
priority = srvs.value["priority"]
}
}
dynamic hosts {
for_each = data.libvirt_network_dns_host_template.host-aliases.*.rendered
content {
ip = hosts.value["ip"]
hostname = hosts.value["hostname"]
}
}
hosts {
ip = var.hosts_info.loadbalancer.ip-address
hostname = "api.${var.dns_domain}"
}
hosts {
ip = var.hosts_info.loadbalancer.ip-address
hostname = "api-int.${var.dns_domain}"
}
}
dhcp {
enabled = true
}
# tag::network-customization[]
xml {
xslt = templatefile("${path.module}/templates/network.xsl", {
dns_domain = var.dns_domain,
hosts = var.hosts_info,
})
}
# end::network-customization[]
}