-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathnetaddress.tf
More file actions
148 lines (134 loc) · 5.37 KB
/
Copy pathnetaddress.tf
File metadata and controls
148 lines (134 loc) · 5.37 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
# 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
###################################################
###################################################
# If vnet_name is not defined, user is supposed also to provide vnet_address_range.
# Both the name and the range will be then used to create the vnet.
#
# User has the freedom to use an existing vnet. When doing so user has the freedom to both
# provide or not provide the associated range.
# If vnet_name is defined, and the vnet_address_range is empty,
# Terraform will try to get the ip range from the real vnet using the data source.
# If vnet_address_range is provided by the user, Terraform will use it
vnet_address_range = (
var.vnet_name == "" ?
var.vnet_address_range :
var.vnet_address_range == "" ? data.azurerm_virtual_network.mynet.0.address_space.0 : var.vnet_address_range
)
subnet_address_range = (
var.subnet_name == "" ?
(var.subnet_address_range == "" ? cidrsubnet(local.vnet_address_range, 3, 1) : var.subnet_address_range) :
(var.subnet_address_range == "" ? data.azurerm_subnet.mysubnet.0.address_prefix : var.subnet_address_range)
)
subnet_netapp_address_range = (
var.subnet_netapp_name == "" ?
(var.subnet_netapp_address_range == "" ? cidrsubnet(local.vnet_address_range, 3, 3) : var.subnet_netapp_address_range) :
(var.subnet_netapp_address_range == "" ? data.azurerm_subnet.mysubnet-netapp.0.address_prefix : var.subnet_netapp_address_range)
)
###################################################
###################################################
# I P s
###################################################
###################################################
# This locals entry is used to store the IP addresses of all the machines.
# Autogenerated addresses example based in 10.74.0.0/24
# Monitoring server: 10.74.0.4
# iscsi: 10.74.0.5 to 10.74.0.5
# Hana ips: 10.74.0.10, 10.74.0.11
# Majority Maker ip: 10.74.0.9
# Hana cluster vip: 10.74.0.12
# Hana cluster vip secondary: 10.74.0.13
# DRBD ips: 10.74.0.6, 10.74.0.7
# DRBD cluster vip: 10.74.0.8
# Netweaver ips: 10.74.0.60, 10.74.0.61, 10.74.0.62, 10.74.0.63
# Netweaver virtual ips: 10.74.0.64, 10.74.0.65, 10.74.0.66, 10.74.0.67
# If the addresses are provided by the user will always have preference
###################################################
# INFRA
monitor_ip_start = 4
monitoring_srv_ip = (
var.monitoring_srv_ip != "" ?
var.monitoring_srv_ip :
cidrhost(local.subnet_address_range, local.monitor_ip_start)
)
iscsi_ip_start = local.monitor_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)
]
)
hana_majority_maker_ip = (
var.hana_majority_maker_ip != "" ?
var.hana_majority_maker_ip :
cidrhost(local.subnet_address_range, local.hana_ip_start - 1)
)
hana_cluster_vip = (
var.hana_cluster_vip != "" ?
var.hana_cluster_vip :
cidrhost(local.subnet_address_range, var.hana_count + local.hana_ip_start)
)
hana_cluster_vip_secondary = (
var.hana_cluster_vip_secondary != "" ?
var.hana_cluster_vip_secondary :
cidrhost(local.subnet_address_range, var.hana_count + local.hana_ip_start + 1)
)
# Has to be in the same subnet of HANA.
# Not used to create any resource in Azure, but only passed to Ansible
# to create cluster resource ocf:heartbeat:IPaddr2
cluster_ip = cidrhost(local.subnet_address_range, var.hana_count + local.hana_ip_start + 2)
###################################################
# DRBD
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)
]
)
drbd_cluster_vip = (
var.drbd_cluster_vip != "" ?
var.drbd_cluster_vip :
cidrhost(local.subnet_address_range, local.drbd_ip_start + 2)
)
###################################################
# 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 = 60
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)
]
)
netweaver_virtual_ips = (
length(var.netweaver_virtual_ips) != 0 ?
var.netweaver_virtual_ips :
[
for ip_index in range(local.netweaver_ip_start + local.netweaver_virtual_ips_count, local.netweaver_ip_start + (local.netweaver_virtual_ips_count * 2)) :
cidrhost(local.subnet_address_range, ip_index)
]
)
}