Skip to content

Commit c7821af

Browse files
committed
feat: append nfs
1 parent bb73449 commit c7821af

9 files changed

+133
-2
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
# Select Subnet on the VPC in a specific Zone
3+
### Also identifies target VPC and target Resource Group
4+
5+
data "ibm_is_subnet" "vpc_subnet" {
6+
name = var.module_var_ibmcloud_vpc_subnet_name
7+
}
8+
9+
data "ibm_is_vpc" "vpc" {
10+
name = data.ibm_is_subnet.vpc_subnet.vpc_name
11+
}
12+
13+
locals {
14+
target_resource_group_id = data.ibm_is_subnet.vpc_subnet.resource_group
15+
target_vpc_id = data.ibm_is_subnet.vpc_subnet.vpc
16+
target_vpc_crn = data.ibm_is_vpc.vpc.crn
17+
target_vpc_availability_zone = data.ibm_is_subnet.vpc_subnet.zone
18+
target_vpc_subnet_range = data.ibm_is_subnet.vpc_subnet.ipv4_cidr_block
19+
target_region = replace(data.ibm_is_subnet.vpc_subnet.zone, "/-[^-]*$/", "")
20+
target_subnet_id = data.ibm_is_subnet.vpc_subnet.id
21+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
resource "ibm_is_share" "file_storage_sapmnt" {
3+
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
4+
name = "${var.module_var_resource_prefix}-nfs-sapmnt"
5+
6+
zone = local.target_vpc_availability_zone
7+
8+
size = 2048
9+
profile = "tier-3iops"
10+
11+
}
12+
13+
resource "ibm_is_share_target" "file_storage_attach_sapmnt" {
14+
count = var.module_var_nfs_boolean_sapmnt ? 1 : 0
15+
name = "${var.module_var_resource_prefix}-nfs-sapmnt-attach"
16+
17+
share = ibm_is_share.file_storage_sapmnt[0].id
18+
vpc = local.target_vpc_id
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
# Mount path
3+
output "output_nfs_fqdn" {
4+
value = ibm_is_share_target.file_storage_attach_sapmnt[0].mount_path
5+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
variable "module_var_resource_prefix" {}
3+
4+
variable "module_var_ibmcloud_vpc_subnet_name" {}
5+
6+
variable "module_var_host_security_group_id" {}
7+
8+
variable "module_var_nfs_boolean_sapmnt" {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Terraform declaration
2+
3+
terraform {
4+
required_version = ">= 1.0"
5+
required_providers {
6+
ibm = {
7+
#source = "localdomain/provider/ibm" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/ibm/1.xx.xx/darwin_amd6
8+
source = "IBM-Cloud/ibm" // Terraform Registry
9+
version = ">=1.45.0"
10+
}
11+
}
12+
}
13+
14+
15+
# Terraform Provider declaration
16+
#
17+
# Nested provider configurations cannot be used with depends_on meta-argument between modules
18+
#
19+
# The calling module block can use either:
20+
# - "providers" argument in the module block
21+
# - none, inherit default (un-aliased) provider configuration
22+
#
23+
# Therefore the below is blank and is only for reference if this module needs to be executed manually
24+
25+
#provider "ibm" {
26+
#
27+
# Define Provider inputs manually
28+
# ibmcloud_api_key = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
29+
#
30+
# Define Provider inputs from given Terraform Variables
31+
# ibmcloud_api_key = var.ibmcloud_api_key
32+
#
33+
# If using IBM Cloud Automation Manager, the Provider declaration values are populated automatically
34+
# from the Cloud Connection credentials (by using Environment Variables)
35+
#
36+
# If using IBM Cloud Schematics, the Provider declaration values are populated automatically
37+
#
38+
# region = var.ibmcloud_region
39+
#
40+
#}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
resource "ibm_is_security_group_rule" "vpc_sg_rule_sap_inbound_nfs" {
3+
group = var.module_var_host_security_group_id
4+
direction = "inbound"
5+
remote = local.target_vpc_subnet_range
6+
tcp {
7+
port_min = 2049
8+
port_max = 2049
9+
}
10+
}
11+
12+
resource "ibm_is_security_group_rule" "vpc_sg_rule_sap_outbound_nfs" {
13+
group = var.module_var_host_security_group_id
14+
direction = "outbound"
15+
remote = local.target_vpc_subnet_range
16+
tcp {
17+
port_min = 2049
18+
port_max = 2049
19+
}
20+
}
21+

ibmcloud_vs/host_provision/build_filesystem_setup.tf

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,24 @@ function main() {
541541
fi
542542
543543
544-
if [[ ${var.module_var_disk_volume_count_sapmnt} -gt 0 ]]
544+
if [[ ${var.module_var_nfs_boolean_sapmnt} == "false" ]] && [[ ${var.module_var_disk_volume_count_sapmnt} -gt 0 ]]
545545
then
546546
physical_volume_partition_runner "/sapmnt" "${var.module_var_disk_volume_capacity_sapmnt}" "4k" "sapmnt" "${var.module_var_filesystem_sapmnt}"
547+
elif [[ ${var.module_var_nfs_boolean_sapmnt} == "true" ]]
548+
then
549+
# Establish IBM Cloud File Share mount path (DNS name and ID e.g. fsf-abcdefg.domain.com:/123456)
550+
ibmcloud_file_share_mount_fqdn_sapmnt='${var.module_var_nfs_boolean_sapmnt ? var.module_var_nfs_fqdn_sapmnt : "null"}'
551+
# Recommend OS mount of the IBM Cloud File Share via the DNS FQDN, which resolves to the IP Address of the IBM Cloud File Share mount path target
552+
# Usually to increase network latency performance for SAP NetWeaver read/write operations, IP Addresses should be used
553+
# However, the NFS protocol performs DNS lookup at mount time, and stores into the local host DNS cache - based on the DNS TTL defined by the IBM Cloud Private DNS Name Server
554+
# As this activity is infrequent, it should not impact performance to set to the FQDN of the IBM Cloud File Share mount path target
555+
# Install NFS
556+
if [ "$os_type" = "rhel" ] ; then yum --assumeyes --debuglevel=1 install nfs-utils ; elif [ "$os_type" = "sles" ] ; then zypper install --no-confirm nfs-client ; fi
557+
# Mount IBM Cloud File Share via DNS FQDN
558+
echo "Mounting NFS for /sapmnt to IBM Cloud File Share mount path target DNS Name: $ibmcloud_file_share_mount_fqdn_sapmnt"
559+
#sudo mount -t nfs4 -o sec=sys,nfsvers=4.1 $ibmcloud_file_share_mount_fqdn_sapmnt /sapmnt
560+
echo "# fstab entries for NFS" >> /etc/fstab
561+
echo "$ibmcloud_file_share_mount_fqdn_sapmnt /sapmnt nfs4 nfsvers=4.1,timeo=600,sec=sys,noatime,proto=tcp 0 0" >> /etc/fstab
547562
fi
548563
549564

ibmcloud_vs/host_provision/host_block_storage.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ resource "ibm_is_volume" "block_volume_usr_sap_tiered" {
161161
}
162162

163163
resource "ibm_is_volume" "block_volume_sapmnt_tiered" {
164-
count = var.module_var_disk_volume_count_sapmnt
164+
count = var.module_var_nfs_boolean_sapmnt ? 0 : var.module_var_disk_volume_count_sapmnt
165165

166166
name = "${var.module_var_virtual_server_hostname}-volume-sapmnt-${count.index}"
167167
resource_group = var.module_var_resource_group_id

ibmcloud_vs/host_provision/module_variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ variable "module_var_disk_volume_capacity_sapmnt" {}
162162
variable "module_var_filesystem_sapmnt" {
163163
default = "xfs"
164164
}
165+
variable "module_var_nfs_boolean_sapmnt" {}
166+
variable "module_var_nfs_fqdn_sapmnt" {}
165167

166168
variable "module_var_disk_swapfile_size_gb" {}
167169
variable "module_var_disk_volume_count_swap" {}

0 commit comments

Comments
 (0)