-
Notifications
You must be signed in to change notification settings - Fork 5
/
ipaddrs.tf
81 lines (66 loc) · 2.89 KB
/
ipaddrs.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
locals {
node_count = "${lookup(var.bastion, "nodes", "1") + lookup(var.master, "nodes", "1") + lookup(var.infra, "nodes", "1") + lookup(var.worker, "nodes", "3") + lookup(var.storage, "nodes", "3")}"
gateways = ["${compact(list(var.public_gateway, var.private_gateway))}"]
}
data "template_file" "bastion_private_ips" {
count = "${lookup(var.bastion, "nodes", "1")}"
# use master ip address array if it's defined, otherwise select one from private ip list
template = "${length(var.bastion_ip_address) == 0 ?
cidrhost(var.private_staticipblock,
1 +
var.private_staticipblock_offset +
count.index) :
element(var.bastion_ip_address, count.index)}"
}
data "template_file" "master_private_ips" {
count = "${lookup(var.master, "nodes", "1")}"
# use master ip address array if it's defined, otherwise select one from private ip list
template = "${length(var.master_ip_address) == 0 ?
cidrhost(var.private_staticipblock,
1 +
var.private_staticipblock_offset +
lookup(var.bastion, "nodes", "1") +
count.index) :
element(var.master_ip_address, count.index)}"
}
data "template_file" "infra_private_ips" {
count = "${lookup(var.infra, "nodes", "1")}"
template = "${length(var.infra_ip_address) == 0 ?
cidrhost(var.private_staticipblock,
1 +
var.private_staticipblock_offset +
lookup(var.bastion, "nodes", "1") +
lookup(var.master, "nodes", "1") +
count.index) :
element(var.infra_ip_address, count.index)}"
}
data "template_file" "worker_private_ips" {
count = "${lookup(var.worker, "nodes", "3")}"
# use worker ip address array if it's defined, otherwise select one from private ip list
template = "${length(var.worker_ip_address) == 0 ?
cidrhost(var.private_staticipblock,
1 +
var.private_staticipblock_offset +
lookup(var.bastion, "nodes", "1") +
lookup(var.master, "nodes", "1") +
lookup(var.infra, "nodes", "1") +
count.index) :
element(var.worker_ip_address, count.index)}"
}
data "template_file" "storage_private_ips" {
count = "${lookup(var.storage, "nodes", "3")}"
template = "${length(var.storage_ip_address) == 0 ?
cidrhost(var.private_staticipblock,
1 +
var.private_staticipblock_offset +
lookup(var.bastion, "nodes", "1") +
lookup(var.master, "nodes", "1") +
lookup(var.infra, "nodes", "1") +
lookup(var.worker, "nodes", "3") +
count.index) :
element(var.storage_ip_address, count.index)}"
}
data "template_file" "public_ips" {
count = "${var.public_network_id != "" ? lookup(var.bastion, "nodes", "1") : 0}"
template = "${cidrhost(var.public_staticipblock, 1 + var.public_staticipblock_offset + count.index)}"
}