-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change default spaging for subnet (#315)
Change how subnet is calculated from vnet. Move all locals about network and IP to a dedicated file. Improve the terraform code documentation.
- Loading branch information
Showing
3 changed files
with
176 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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_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) | ||
] | ||
) | ||
|
||
} |