diff --git a/cspell.json b/cspell.json index 97fcea9a..2cdd91cd 100644 --- a/cspell.json +++ b/cspell.json @@ -28,11 +28,15 @@ "isreg", "keygen", "logd", + "netweaver", "noqa", "nosum", "numluns", "nvme", "publickey", + "pytest", + "PYTHONPATH", + "qesap", "Quickstart", "reuseaddr", "rsyslog", @@ -45,10 +49,7 @@ "usrsaplv", "usrsapvg", "venv", - "yast", - "qesap", - "PYTHONPATH", - "pytest" + "yast" ], "languageSettings": [ { diff --git a/terraform/aws/main.tf b/terraform/aws/main.tf index 9332e1c3..150048aa 100644 --- a/terraform/aws/main.tf +++ b/terraform/aws/main.tf @@ -47,7 +47,7 @@ module "common_variables" { authorized_keys = var.authorized_keys authorized_user = var.admin_user monitoring_enabled = var.monitoring_enabled - monitoring_srv_ip = var.monitoring_enabled ? local.monitoring_ip : "" + monitoring_srv_ip = var.monitoring_enabled ? local.monitoring_srv_ip : "" hana_instance_number = var.hana_instance_number hana_cost_optimized_instance_number = var.hana_cost_optimized_instance_number hana_primary_site = var.hana_primary_site @@ -183,7 +183,7 @@ module "monitoring" { vm_size = var.monitor_instancetype key_name = aws_key_pair.key-pair.key_name security_group_id = local.security_group_id - monitoring_srv_ip = local.monitoring_ip + monitoring_srv_ip = local.monitoring_srv_ip availability_zones = data.aws_availability_zones.available.names os_image = local.monitoring_os_image os_owner = local.monitoring_os_owner diff --git a/terraform/aws/netaddress.tf b/terraform/aws/netaddress.tf index d8b57616..1c55c3f9 100644 --- a/terraform/aws/netaddress.tf +++ b/terraform/aws/netaddress.tf @@ -1,8 +1,7 @@ -# This file is used to calculate and store in some local variables +# 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 @@ -104,7 +103,7 @@ locals { ################################################### # INFRA - monitoring_ip = ( + monitoring_srv_ip = ( var.monitoring_srv_ip != "" ? var.monitoring_srv_ip : cidrhost(local.infra_subnet_address_range, local.ip_start) diff --git a/terraform/azure/main.tf b/terraform/azure/main.tf index c10e3777..65bd3d9e 100644 --- a/terraform/azure/main.tf +++ b/terraform/azure/main.tf @@ -35,7 +35,7 @@ module "common_variables" { authorized_keys = var.authorized_keys authorized_user = var.admin_user monitoring_enabled = var.monitoring_enabled - monitoring_srv_ip = var.monitoring_enabled ? local.monitoring_ip : "" + monitoring_srv_ip = var.monitoring_enabled ? local.monitoring_srv_ip : "" hana_hwcct = var.hwcct hana_instance_number = var.hana_instance_number hana_cost_optimized_instance_number = var.hana_cost_optimized_instance_number @@ -199,7 +199,7 @@ module "monitoring" { storage_account = azurerm_storage_account.mytfstorageacc.primary_blob_endpoint monitoring_uri = local.monitoring_os_image_uri os_image = local.monitoring_os_image - monitoring_srv_ip = local.monitoring_ip + monitoring_srv_ip = local.monitoring_srv_ip } module "iscsi_server" { diff --git a/terraform/azure/netaddress.tf b/terraform/azure/netaddress.tf index 8e3a4afb..71760011 100644 --- a/terraform/azure/netaddress.tf +++ b/terraform/azure/netaddress.tf @@ -57,7 +57,7 @@ locals { ################################################### # INFRA monitor_ip_start = 4 - monitoring_ip = ( + monitoring_srv_ip = ( var.monitoring_srv_ip != "" ? var.monitoring_srv_ip : cidrhost(local.subnet_address_range, local.monitor_ip_start) diff --git a/terraform/gcp/infrastructure.tf b/terraform/gcp/infrastructure.tf index 936a2ae6..65de3c6d 100644 --- a/terraform/gcp/infrastructure.tf +++ b/terraform/gcp/infrastructure.tf @@ -16,9 +16,8 @@ locals { network_link = var.vpc_name == "" ? google_compute_network.ha_network.0.self_link : format( "https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s", var.project, var.vpc_name) - vpc_name = var.vpc_name == "" ? google_compute_network.ha_network.0.name : var.vpc_name - subnet_name = var.subnet_name == "" ? google_compute_subnetwork.ha_subnet.0.name : var.subnet_name - 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) + vpc_name = var.vpc_name == "" ? google_compute_network.ha_network.0.name : var.vpc_name + subnet_name = var.subnet_name == "" ? google_compute_subnetwork.ha_subnet.0.name : var.subnet_name create_firewall = var.create_firewall_rules ? 1 : 0 ibsm_count = (var.ibsm_vpc_name != "" && var.ibsm_subnet_name != "" && var.ibsm_subnet_region != "") ? 1 : 0 diff --git a/terraform/gcp/main.tf b/terraform/gcp/main.tf index cf66898f..37f89dcc 100644 --- a/terraform/gcp/main.tf +++ b/terraform/gcp/main.tf @@ -1,53 +1,7 @@ -# 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 locals { - monitoring_srv_ip = var.monitoring_srv_ip != "" ? var.monitoring_srv_ip : cidrhost(local.subnet_address_range, 4) - iscsi_ip_start = 5 - 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_ip_start = 10 - hana_ips = length(var.hana_ips) != 0 ? var.hana_ips : [for ip_index in range(local.hana_ip_start, local.hana_ip_start + var.hana_count) : cidrhost(local.subnet_address_range, ip_index)] - - # 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 - - # 2 is hardcoded for drbd because we always deploy 4 machines - drbd_ip_start = 20 - 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_xscs_server_count = var.netweaver_enabled ? (var.netweaver_ha_enabled ? 2 : 1) : 0 netweaver_count = var.netweaver_enabled ? local.netweaver_xscs_server_count + var.netweaver_app_server_count : 0 - netweaver_virtual_ips_count = var.netweaver_ha_enabled ? max(local.netweaver_count, 3) : max(local.netweaver_count, 2) # We need at least 2 virtual ips, if ASCS and PAS are in the same machine - - 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)] - 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)] # same 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)] # different subnet as netweaver hosts - 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 # Check if iscsi server has to be created use_sbd = var.hana_cluster_fencing_mechanism == "sbd" || var.drbd_cluster_fencing_mechanism == "sbd" || var.netweaver_cluster_fencing_mechanism == "sbd" diff --git a/terraform/gcp/netaddress.tf b/terraform/gcp/netaddress.tf new file mode 100644 index 00000000..a183cc97 --- /dev/null +++ b/terraform/gcp/netaddress.tf @@ -0,0 +1,186 @@ +# 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 + ) +} +