Skip to content

Commit 2b34d1f

Browse files
committed
Merge branch 'master' of ssh://github.com/SUSE/ha-sap-terraform-deployments
2 parents 615023a + bb4aca3 commit 2b34d1f

File tree

16 files changed

+97
-60
lines changed

16 files changed

+97
-60
lines changed

aws/infrastructure.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ locals {
3333
for index in range(2) : cidrsubnet(local.vpc_address_range, 8, index + var.hana_count + 2 + 1)]
3434
}
3535

36-
# EFS storage for nfs share used by Netweaver for /usr/sap/{sid} and /sapmnt
37-
# It will be created for netweaver only when drbd is disabled
38-
resource "aws_efs_file_system" "netweaver-efs" {
39-
count = var.netweaver_enabled == true && var.drbd_enabled == false ? 1 : 0
40-
creation_token = "${local.deployment_name}-netweaver-efs"
41-
performance_mode = var.netweaver_efs_performance_mode
42-
43-
tags = {
44-
Name = "${local.deployment_name}-efs"
45-
}
46-
}
47-
4836
# AWS key pair
4937
resource "aws_key_pair" "key-pair" {
5038
key_name = "${local.deployment_name} - terraform"

aws/main.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ module "common_variables" {
125125
netweaver_swpm_sar = var.netweaver_swpm_sar
126126
netweaver_sapexe_folder = var.netweaver_sapexe_folder
127127
netweaver_additional_dvds = var.netweaver_additional_dvds
128-
netweaver_nfs_share = var.drbd_enabled ? "${local.drbd_cluster_vip}:/${var.netweaver_sid}" : "${join("", aws_efs_file_system.netweaver-efs.*.dns_name)}:"
128+
netweaver_nfs_share = var.drbd_enabled ? "${local.drbd_cluster_vip}:/${var.netweaver_sid}" : var.netweaver_nfs_share
129129
netweaver_sapmnt_path = var.netweaver_sapmnt_path
130130
netweaver_hana_ip = var.hana_ha_enabled ? local.hana_cluster_vip : element(local.hana_ips, 0)
131131
netweaver_hana_sid = var.hana_sid
@@ -227,8 +227,7 @@ module "netweaver_node" {
227227
key_name = aws_key_pair.key-pair.key_name
228228
security_group_id = local.security_group_id
229229
route_table_id = aws_route_table.route-table.id
230-
efs_enable_mount = var.netweaver_enabled == true && var.drbd_enabled == false ? true : false
231-
efs_file_system_id = join("", aws_efs_file_system.netweaver-efs.*.id)
230+
efs_performance_mode = var.netweaver_efs_performance_mode
232231
aws_credentials = var.aws_credentials
233232
aws_access_key_id = var.aws_access_key_id
234233
aws_secret_access_key = var.aws_secret_access_key

aws/modules/netweaver_node/main.tf

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
locals {
2-
vm_count = var.xscs_server_count + var.app_server_count
3-
create_ha_infra = local.vm_count > 1 && var.common_variables["netweaver"]["ha_enabled"] ? 1 : 0
4-
app_start_index = local.create_ha_infra == 1 ? 2 : 1
5-
hostname = var.common_variables["deployment_name_in_hostname"] ? format("%s-%s", var.common_variables["deployment_name"], var.name) : var.name
2+
vm_count = var.xscs_server_count + var.app_server_count
3+
create_ha_infra = local.vm_count > 1 && var.common_variables["netweaver"]["ha_enabled"] ? 1 : 0
4+
app_start_index = local.create_ha_infra == 1 ? 2 : 1
5+
hostname = var.common_variables["deployment_name_in_hostname"] ? format("%s-%s", var.common_variables["deployment_name"], var.name) : var.name
6+
shared_storage_efs = var.common_variables["netweaver"]["shared_storage_type"] == "efs" ? 1 : 0
67
}
78

89
# Network resources: subnets, routes, etc
@@ -54,9 +55,21 @@ resource "aws_route" "nw-app-route" {
5455
network_interface_id = aws_instance.netweaver[local.app_start_index + count.index].primary_network_interface_id
5556
}
5657

58+
# EFS storage for nfs share used by Netweaver for /usr/sap/{sid} and /sapmnt
59+
# It will be created for netweaver only when drbd is disabled
60+
resource "aws_efs_file_system" "netweaver-efs" {
61+
count = local.vm_count > 0 ? local.shared_storage_efs : 0
62+
creation_token = "${var.common_variables["deployment_name"]}-netweaver-efs"
63+
performance_mode = var.efs_performance_mode
64+
65+
tags = {
66+
Name = "${var.common_variables["deployment_name"]}-efs"
67+
}
68+
}
69+
5770
resource "aws_efs_mount_target" "netweaver-efs-mount-target" {
58-
count = local.vm_count > 0 && var.efs_enable_mount ? min(local.vm_count, 2) : 0
59-
file_system_id = var.efs_file_system_id
71+
count = local.vm_count > 0 && local.shared_storage_efs == 1 ? min(local.vm_count, 2) : 0
72+
file_system_id = aws_efs_file_system.netweaver-efs.0.id
6073
subnet_id = element(aws_subnet.netweaver-subnet.*.id, count.index)
6174
security_groups = [var.security_group_id]
6275
}

aws/modules/netweaver_node/salt_provisioner.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ iscsi_srv_ip: ${var.iscsi_srv_ip}
4242
app_server_count: ${var.app_server_count}
4343
netweaver_inst_disk_device: /dev/nvme1n1
4444
s3_bucket: ${var.s3_bucket}
45+
efs_mount_ip:
46+
sapmnt: [ ${local.shared_storage_efs == 1 ? join("", aws_efs_file_system.netweaver-efs.*.dns_name) : ""} ]
4547
EOF
4648
destination = "/tmp/grains"
4749
}

aws/modules/netweaver_node/variables.tf

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,10 @@ variable "route_table_id" {
6161
description = "Route table id"
6262
}
6363

64-
variable "efs_enable_mount" {
65-
type = bool
66-
description = "Enable the mount operation on the EFS storage"
67-
}
68-
69-
variable "efs_file_system_id" {
64+
variable "efs_performance_mode" {
7065
type = string
71-
description = "AWS efs file system ID to be used by EFS mount target"
66+
description = "Performance mode of the EFS storage used by Netweaver"
67+
default = "generalPurpose"
7268
}
7369

7470
variable "aws_credentials" {

aws/terraform.tfvars.example

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,6 @@ hana_inst_master = "s3://sapdata/sap_inst_media/51053381"
335335
#netweaver_os_image = "suse-sles-sap-15-sp1-byos"
336336
#netweaver_os_owner = "amazon"
337337

338-
#AWS efs performance mode used by netweaver nfs share, if efs storage is used
339-
#netweaver_efs_performance_mode = "generalPurpose"
340338
#netweaver_ips = ["10.0.2.7", "10.0.3.8", "10.0.2.9", "10.0.3.10"]
341339
#netweaver_virtual_ips = ["192.168.1.20", "192.168.1.21", "192.168.1.22", "192.168.1.23"]
342340

@@ -381,6 +379,14 @@ hana_inst_master = "s3://sapdata/sap_inst_media/51053381"
381379
# Example:
382380
#netweaver_product_id = "NW750.HDB.ABAPHA"
383381

382+
#########################
383+
# Netweaver shared storage variables
384+
# Needed if Netweaver is deployed HA
385+
#########################
386+
#netweaver_shared_storage_type = "efs" # drbd,efs supported at the moment (default: "efs")
387+
#AWS efs performance mode used by netweaver nfs share, if efs storage is used
388+
#netweaver_efs_performance_mode = "generalPurpose"
389+
384390
# Path where netweaver sapmnt data is stored.
385391
#netweaver_sapmnt_path = "/sapmnt"
386392

aws/variables.tf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,12 @@ variable "netweaver_cluster_fencing_mechanism" {
805805
}
806806
}
807807

808+
variable "netweaver_nfs_share" {
809+
description = "URL of the NFS share where /sapmnt and /usr/sap/{sid}/SYS will be mounted. This folder must have the sapmnt and usrsapsys folders. This parameter can be omitted if drbd_enabled is set to true, as a HA nfs share will be deployed by the project. Finally, if it is not used or set empty, these folders are created locally (for single machine deployments)"
810+
type = string
811+
default = ""
812+
}
813+
808814
variable "netweaver_sapmnt_path" {
809815
description = "Path where sapmnt folder is stored"
810816
type = string
@@ -866,14 +872,14 @@ variable "netweaver_ha_enabled" {
866872
}
867873

868874
variable "netweaver_shared_storage_type" {
869-
description = "shared Storage type to use for Netweaver deployment - not supported yet for this cloud provider yet"
875+
description = "shared Storage type to use for Netweaver deployment"
870876
type = string
871-
default = ""
877+
default = "efs"
872878
validation {
873879
condition = (
874-
can(regex("^(|)$", var.netweaver_shared_storage_type))
880+
can(regex("^(drbd|efs)$", var.netweaver_shared_storage_type))
875881
)
876-
error_message = "Invalid Netweaver shared storage type. Options: none."
882+
error_message = "Invalid Netweaver shared storage type. Options: drbd|efs."
877883
}
878884
}
879885

doc/netweaver.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ The deployment will create 4 new virtual machines to host the NetWeaver environm
1111

1212
Besides the standard installation, an additional HA cluster might be added in top of the ASCS and ERS communication to assure high availability between these two components using the *sap_suse_cluster_connector* (HA is enabled by default).
1313

14-
More details in the official Suse documentation:
14+
More details in the official Suse documentation:
1515

16-
[SAP NetWeaver Enqueue Replication 1 High Availability Cluster - Setup Guide for SAP NetWeaver 7.40 and 7.50](https://documentation.suse.com/sbp/all/html/SAP_NW740_SLE15_SetupGuide/index.html) [pdf (en)](https://documentation.suse.com/sbp/all/pdf/SAP_NW740_SLE15_SetupGuide_color_en.pdf)
16+
[SAP NetWeaver Enqueue Replication 1 High Availability Cluster - Setup Guide for SAP NetWeaver 7.40 and 7.50](https://documentation.suse.com/sbp/all/html/SAP-nw740-sle15-setupguide/index.html) [pdf (en)](https://documentation.suse.com/sbp/all/pdf/SAP-nw740-sle15-setupguide_color_en.pdf)
1717

18-
[SAP S/4 HANA - Enqueue Replication 2 High Availability Cluster - Setup Guide](https://documentation.suse.com/sbp/all/html/SAP_S4HA10_SetupGuide-SLE15/index.html)
18+
[SAP S/4 HANA - Enqueue Replication 2 High Availability Cluster - Setup Guide](https://documentation.suse.com/sbp/all/html/SAP-S4HA10-setupguide-sle15/index.html) [pdf (en)](https://documentation.suse.com/sbp/all/pdf/SAP-S4HA10-setupguide-sle15_color_en.pdf)
1919

2020
The deployment is performed using the [sapnwbootstrap-formula](https://github.com/SUSE/sapnwbootstrap-formula).
2121

gcp/infrastructure.tf

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ data "google_compute_subnetwork" "current-subnet" {
1111

1212
locals {
1313
deployment_name = var.deployment_name != "" ? var.deployment_name : terraform.workspace
14+
# only use 2 compute zones to have an even distribution of nodes
15+
compute_zones = slice(data.google_compute_zones.available.names, 0, 2)
1416

1517
network_link = var.vpc_name == "" ? google_compute_network.ha_network.0.self_link : format(
1618
"https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s", var.project, var.vpc_name)
@@ -58,19 +60,21 @@ resource "google_compute_firewall" "ha_firewall_allow_internal" {
5860
}
5961

6062
resource "google_compute_firewall" "ha_firewall_allow_icmp" {
61-
count = local.create_firewall
62-
name = "${local.deployment_name}-fw-icmp"
63-
network = local.vpc_name
63+
count = local.create_firewall
64+
name = "${local.deployment_name}-fw-icmp"
65+
network = local.vpc_name
66+
source_ranges = ["0.0.0.0/0"]
6467

6568
allow {
6669
protocol = "icmp"
6770
}
6871
}
6972

7073
resource "google_compute_firewall" "ha_firewall_allow_tcp" {
71-
count = local.create_firewall
72-
name = "${local.deployment_name}-fw-tcp"
73-
network = local.vpc_name
74+
count = local.create_firewall
75+
name = "${local.deployment_name}-fw-tcp"
76+
network = local.vpc_name
77+
source_ranges = ["0.0.0.0/0"]
7478

7579
allow {
7680
protocol = "tcp"
@@ -88,7 +92,7 @@ module "bastion" {
8892
region = var.region
8993
os_image = local.bastion_os_image
9094
vm_size = "custom-1-2048"
91-
compute_zones = data.google_compute_zones.available.names
95+
compute_zones = local.compute_zones
9296
network_link = local.network_link
9397
snet_address_range = cidrsubnet(cidrsubnet(local.subnet_address_range, -4, 0), 4, 2)
9498
}

gcp/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ module "drbd_node" {
175175
bastion_host = module.bastion.public_ip
176176
drbd_count = var.drbd_enabled == true ? 2 : 0
177177
machine_type = var.drbd_machine_type
178-
compute_zones = data.google_compute_zones.available.names
178+
compute_zones = local.compute_zones
179179
network_name = local.vpc_name
180180
network_subnet_name = local.subnet_name
181181
os_image = local.drbd_os_image
@@ -203,7 +203,7 @@ module "netweaver_node" {
203203
xscs_server_count = local.netweaver_xscs_server_count
204204
app_server_count = var.netweaver_enabled ? var.netweaver_app_server_count : 0
205205
machine_type = var.netweaver_machine_type
206-
compute_zones = data.google_compute_zones.available.names
206+
compute_zones = local.compute_zones
207207
network_name = local.vpc_name
208208
network_subnet_name = local.subnet_name
209209
os_image = local.netweaver_os_image
@@ -228,7 +228,7 @@ module "hana_node" {
228228
bastion_host = module.bastion.public_ip
229229
hana_count = var.hana_count
230230
machine_type = var.machine_type
231-
compute_zones = data.google_compute_zones.available.names
231+
compute_zones = local.compute_zones
232232
network_name = local.vpc_name
233233
network_subnet_name = local.subnet_name
234234
os_image = local.hana_os_image
@@ -255,7 +255,7 @@ module "monitoring" {
255255
network_domain = var.monitoring_network_domain == "" ? var.network_domain : var.monitoring_network_domain
256256
bastion_host = module.bastion.public_ip
257257
monitoring_enabled = var.monitoring_enabled
258-
compute_zones = data.google_compute_zones.available.names
258+
compute_zones = local.compute_zones
259259
network_subnet_name = local.subnet_name
260260
os_image = local.monitoring_os_image
261261
monitoring_srv_ip = local.monitoring_srv_ip
@@ -274,7 +274,7 @@ module "iscsi_server" {
274274
bastion_host = module.bastion.public_ip
275275
iscsi_count = local.iscsi_enabled == true ? 1 : 0
276276
machine_type = var.machine_type_iscsi_server
277-
compute_zones = data.google_compute_zones.available.names
277+
compute_zones = local.compute_zones
278278
network_subnet_name = local.subnet_name
279279
os_image = local.iscsi_os_image
280280
host_ips = [local.iscsi_srv_ip]

0 commit comments

Comments
 (0)