-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathnetaddress.tf
More file actions
186 lines (166 loc) · 6.35 KB
/
Copy pathnetaddress.tf
File metadata and controls
186 lines (166 loc) · 6.35 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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# This file is used to calculate and store in some locals (local variables)
# the IP addresses of all the machines.
locals {
###################################################
###################################################
# R A N G E s
###################################################
###################################################
# There is a hierarchy of nested ranges
subnet_address_range = (
var.subnet_name == "" ?
var.ip_cidr_range :
var.ip_cidr_range == "" ? data.google_compute_subnetwork.current-subnet.0.ip_cidr_range : var.ip_cidr_range
)
###################################################
###################################################
# I P s
###################################################
###################################################
# This locals entry is used to store the IP addresses of all the machines.
# Autogenerated addresses example based in 10.0.0.0/24
# Iscsi server: 10.0.0.4
# Monitoring: 10.0.0.5
# Hana ips: 10.0.0.10, 10.0.0.11
# Hana cluster vip: 10.0.0.12
# Hana cluster vip secondary: 10.0.0.13
# DRBD ips: 10.0.0.20, 10.0.0.21
# DRBD cluster vip: 10.0.0.22
# Netweaver ips: 10.0.0.30, 10.0.0.31, 10.0.0.32, 10.0.0.33
# Netweaver virtual ips: 10.0.0.34, 10.0.0.35, 10.0.0.36, 10.0.0.37
# If the addresses are provided by the user they will always have preference
ip_start = 4
###################################################
# INFRA
monitoring_srv_ip = (
var.monitoring_srv_ip != "" ?
var.monitoring_srv_ip :
cidrhost(local.subnet_address_range, local.ip_start)
)
iscsi_ip_start = local.ip_start + 1
iscsi_ips = (
length(var.iscsi_ips) != 0 ?
var.iscsi_ips :
[
for ip_index in range(local.iscsi_ip_start, var.iscsi_count + local.iscsi_ip_start) :
cidrhost(local.subnet_address_range, ip_index)
]
)
###################################################
# HANA
hana_ip_start = 10
hana_ips = (
length(var.hana_ips) != 0 ?
var.hana_ips :
[
for ip_index in range(var.hana_count) :
cidrhost(local.subnet_address_range, ip_index + local.hana_ip_start)
]
)
# Virtual IP addresses if a load balancer is used. In this case the virtual ip address belongs to the same subnet than the machines
hana_cluster_vip_lb = (
var.hana_cluster_vip != "" ?
var.hana_cluster_vip :
cidrhost(local.subnet_address_range, local.hana_ip_start + var.hana_count)
)
hana_cluster_vip_secondary_lb = (
var.hana_cluster_vip_secondary != "" ?
var.hana_cluster_vip_secondary :
cidrhost(local.subnet_address_range, local.hana_ip_start + var.hana_count + 1)
)
# Virtual IP addresses if a route is used. In this case the virtual ip address belongs to a different subnet than the machines
hana_cluster_vip_route = (
var.hana_cluster_vip != "" ?
var.hana_cluster_vip :
cidrhost(cidrsubnet(local.subnet_address_range, -8, 0), 256 + local.hana_ip_start + var.hana_count)
)
hana_cluster_vip_secondary_route = (
var.hana_cluster_vip_secondary != "" ?
var.hana_cluster_vip_secondary :
cidrhost(cidrsubnet(local.subnet_address_range, -8, 0), 256 + local.hana_ip_start + var.hana_count + 1)
)
# Select the final virtual ip address
hana_cluster_vip = (
var.hana_cluster_vip_mechanism == "load-balancer" ?
local.hana_cluster_vip_lb :
local.hana_cluster_vip_route
)
hana_cluster_vip_secondary = (
var.hana_cluster_vip_mechanism == "load-balancer" ?
local.hana_cluster_vip_secondary_lb :
local.hana_cluster_vip_secondary_route
)
###################################################
# DRBD
# 2 is hardcoded for drbd because we always deploy 4 machines
drbd_ip_start = 6
drbd_ips = (
length(var.drbd_ips) != 0 ?
var.drbd_ips :
[
for ip_index in range(local.drbd_ip_start, local.drbd_ip_start + 2) :
cidrhost(local.subnet_address_range, ip_index)
]
)
# Virtual IP addresses if a route is used. In this case the virtual ip address belongs to a different subnet than the machines
drbd_cluster_vip_lb = (
var.drbd_cluster_vip != "" ?
var.drbd_cluster_vip :
cidrhost(local.subnet_address_range, local.drbd_ip_start + 2)
)
drbd_cluster_vip_route = (
var.drbd_cluster_vip != "" ?
var.drbd_cluster_vip :
cidrhost(cidrsubnet(local.subnet_address_range, -8, 0), 256 + local.drbd_ip_start + 2)
)
drbd_cluster_vip = (
var.drbd_cluster_vip_mechanism == "load-balancer" ?
local.drbd_cluster_vip_lb :
local.drbd_cluster_vip_route
)
###################################################
# NETWEAVER
# We need at least 2 virtual ips, if ASCS and PAS are in the same machine
netweaver_virtual_ips_count = var.netweaver_ha_enabled ? max(local.netweaver_count, 3) : max(local.netweaver_count, 2)
netweaver_ip_start = 30
netweaver_ips = (
length(var.netweaver_ips) != 0 ?
var.netweaver_ips :
[
for ip_index in range(local.netweaver_ip_start, local.netweaver_ip_start + local.netweaver_count) :
cidrhost(local.subnet_address_range, ip_index)
]
)
# same subnet as netweaver hosts
netweaver_virtual_ips_lb_xscs = (
length(var.netweaver_virtual_ips) != 0 ?
var.netweaver_virtual_ips :
[
for ip_index in range(local.netweaver_ip_start, local.netweaver_ip_start + local.netweaver_xscs_server_count) :
cidrhost(local.subnet_address_range, ip_index + 4)
]
)
# different subnet as netweaver hosts
netweaver_virtual_ips_lb_app = (
length(var.netweaver_virtual_ips) != 0 ?
var.netweaver_virtual_ips :
[
for ip_index in range(local.netweaver_ip_start + local.netweaver_xscs_server_count, local.netweaver_ip_start + local.netweaver_xscs_server_count + var.netweaver_app_server_count) :
cidrhost(cidrsubnet(local.subnet_address_range, -8, 0), 256 + ip_index + 4)
]
)
# different subnet as netweaver hosts
netweaver_virtual_ips_route = (
length(var.netweaver_virtual_ips) != 0 ?
var.netweaver_virtual_ips :
[
for ip_index in range(local.netweaver_ip_start, local.netweaver_ip_start + local.netweaver_virtual_ips_count) :
cidrhost(cidrsubnet(local.subnet_address_range, -8, 0), 256 + ip_index + 4)
]
)
netweaver_virtual_ips = (
var.netweaver_cluster_vip_mechanism == "load-balancer" ?
concat(local.netweaver_virtual_ips_lb_xscs, local.netweaver_virtual_ips_lb_app) :
local.netweaver_virtual_ips_route
)
}