diff --git a/.github/workflows/terraform_validate_100.yml b/.github/workflows/terraform_validate_100.yml index 96bdfe7..b4a93c3 100644 --- a/.github/workflows/terraform_validate_100.yml +++ b/.github/workflows/terraform_validate_100.yml @@ -15,11 +15,11 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - max-parallel: 10 + max-parallel: 25 matrix: terraform_ver: [~1.0.0] # Job matrix can generate a maximum of 256 jobs per workflow run sap_solution_scenario: [sap_bw4hana_single_node_install, sap_ecc_hana_single_node_install, sap_ecc_hana_single_node_system_copy_homogeneous_hdb, sap_ecc_ibmdb2_single_node_install, sap_ecc_oracledb_single_node_install, sap_ecc_sapase_single_node_install, sap_ecc_sapmaxdb_single_node_install, sap_hana_single_node_install, sap_nwas_abap_hana_install, sap_nwas_abap_ibmdb2_install, sap_nwas_abap_oracledb_install, sap_nwas_abap_sapase_install, sap_nwas_abap_sapmaxdb_install, sap_nwas_java_ibmdb2_install, sap_nwas_java_sapase_install, sap_s4hana_single_node_install, sap_s4hana_single_node_install_maintenance_plan, sap_s4hana_single_node_system_copy_homogeneous_hdb] - infrastructure_platform: [aws_ec2_instance, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] + infrastructure_platform: [aws_ec2_instance, gcp_ce_vm, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] steps: - name: Checkout uses: actions/checkout@v3.1.0 diff --git a/.github/workflows/terraform_validate_110.yml b/.github/workflows/terraform_validate_110.yml index 77c27b6..e76b194 100644 --- a/.github/workflows/terraform_validate_110.yml +++ b/.github/workflows/terraform_validate_110.yml @@ -15,11 +15,11 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - max-parallel: 10 + max-parallel: 25 matrix: terraform_ver: [~1.1.0] # Job matrix can generate a maximum of 256 jobs per workflow run sap_solution_scenario: [sap_bw4hana_single_node_install, sap_ecc_hana_single_node_install, sap_ecc_hana_single_node_system_copy_homogeneous_hdb, sap_ecc_ibmdb2_single_node_install, sap_ecc_oracledb_single_node_install, sap_ecc_sapase_single_node_install, sap_ecc_sapmaxdb_single_node_install, sap_hana_single_node_install, sap_nwas_abap_hana_install, sap_nwas_abap_ibmdb2_install, sap_nwas_abap_oracledb_install, sap_nwas_abap_sapase_install, sap_nwas_abap_sapmaxdb_install, sap_nwas_java_ibmdb2_install, sap_nwas_java_sapase_install, sap_s4hana_single_node_install, sap_s4hana_single_node_install_maintenance_plan, sap_s4hana_single_node_system_copy_homogeneous_hdb] - infrastructure_platform: [aws_ec2_instance, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] + infrastructure_platform: [aws_ec2_instance, gcp_ce_vm, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] steps: - name: Checkout uses: actions/checkout@v3.1.0 diff --git a/.github/workflows/terraform_validate_120.yml b/.github/workflows/terraform_validate_120.yml index 9ff7caa..571b4b5 100644 --- a/.github/workflows/terraform_validate_120.yml +++ b/.github/workflows/terraform_validate_120.yml @@ -15,11 +15,11 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - max-parallel: 10 + max-parallel: 25 matrix: terraform_ver: [~1.2.0] # Job matrix can generate a maximum of 256 jobs per workflow run sap_solution_scenario: [sap_bw4hana_single_node_install, sap_ecc_hana_single_node_install, sap_ecc_hana_single_node_system_copy_homogeneous_hdb, sap_ecc_ibmdb2_single_node_install, sap_ecc_oracledb_single_node_install, sap_ecc_sapase_single_node_install, sap_ecc_sapmaxdb_single_node_install, sap_hana_single_node_install, sap_nwas_abap_hana_install, sap_nwas_abap_ibmdb2_install, sap_nwas_abap_oracledb_install, sap_nwas_abap_sapase_install, sap_nwas_abap_sapmaxdb_install, sap_nwas_java_ibmdb2_install, sap_nwas_java_sapase_install, sap_s4hana_single_node_install, sap_s4hana_single_node_install_maintenance_plan, sap_s4hana_single_node_system_copy_homogeneous_hdb] - infrastructure_platform: [aws_ec2_instance, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] + infrastructure_platform: [aws_ec2_instance, gcp_ce_vm, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] steps: - name: Checkout uses: actions/checkout@v3.1.0 diff --git a/.github/workflows/terraform_validate_130.yml b/.github/workflows/terraform_validate_130.yml index c75c26b..dbe36ae 100644 --- a/.github/workflows/terraform_validate_130.yml +++ b/.github/workflows/terraform_validate_130.yml @@ -15,11 +15,11 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false - max-parallel: 10 + max-parallel: 25 matrix: terraform_ver: [~1.3.0] # Job matrix can generate a maximum of 256 jobs per workflow run sap_solution_scenario: [sap_bw4hana_single_node_install, sap_ecc_hana_single_node_install, sap_ecc_hana_single_node_system_copy_homogeneous_hdb, sap_ecc_ibmdb2_single_node_install, sap_ecc_oracledb_single_node_install, sap_ecc_sapase_single_node_install, sap_ecc_sapmaxdb_single_node_install, sap_hana_single_node_install, sap_nwas_abap_hana_install, sap_nwas_abap_ibmdb2_install, sap_nwas_abap_oracledb_install, sap_nwas_abap_sapase_install, sap_nwas_abap_sapmaxdb_install, sap_nwas_java_ibmdb2_install, sap_nwas_java_sapase_install, sap_s4hana_single_node_install, sap_s4hana_single_node_install_maintenance_plan, sap_s4hana_single_node_system_copy_homogeneous_hdb] - infrastructure_platform: [aws_ec2_instance, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] + infrastructure_platform: [aws_ec2_instance, gcp_ce_vm, ibmcloud_vs, ibmcloud_powervs, ibmpowervc, msazure_vm, vmware_vm] steps: - name: Checkout uses: actions/checkout@v3.1.0 diff --git a/README.md b/README.md index b2ad022..e5fc49e 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,16 @@ These Terraform Templates for SAP are designed to be: - use Terraform as Infrastructure-as-Code (IaC), - and Ansible as Configuration-as-Code (CaC) for configuraton of OS and installation of SAP Software. -**Please read the [full documentation](/docs#readme) for how-to guidance, requirements, and all other details** +**Please read the [full documentation](/docs#readme) for how-to guidance, requirements, and all other details. Summary documentation is below:** +- [Terraform Templates for SAP - summary diagram](#terraform-templates-for-sap---summary-diagram) +- [Terraform Templates for SAP - available scenarios](#terraform-templates-for-sap---available-scenarios) +- [Terraform Templates for SAP - infrastructure provisioning](#terraform-templates-for-sap---infrastructure-provisioning) +- [Disclaimer](#disclaimer) -**Summary diagram:** + +--- + +# Terraform Templates for SAP - summary diagram ![Terraform execution flow](./docs/terraform_sap_summary.svg) @@ -22,24 +29,24 @@ These Terraform Templates for SAP are designed to be: | SAP Software solution scenario | Infrastructure Platform | |:--- |:--- | -| **SAP HANA 2.0 (any version)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP S/4HANA (2021, 2022)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP S/4HANA (2020, 2021, 2022)**
single-node installation,
using SAP Maintenance Planner Stack XML
(to run SUM and SPAM / SAINT) | *Coming Soon: GCP VM, OVirt VM* | -| **SAP S/4HANA (1909, 2020, 2021, 2022)**
single-node System Copy installation
(Homogeneous with SAP HANA Backup / Recovery) | *Coming Soon: GCP VM, OVirt VM* | -| **SAP BW/4HANA (2021)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP ECC on SAP HANA (EHP7, EHP8)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP ECC on SAP HANA (EHP7, EHP8)**
single-node System Copy installation
(Homogeneous with SAP HANA Backup / Recovery) | *Coming Soon: GCP VM, OVirt VM* | -| **SAP ECC on IBM Db2 (EHP7, EHP8)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP ECC on Oracle DB (EHP7, EHP8)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP ECC on SAP ASE (EHP7, EHP8)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP ECC on SAP MaxDB (EHP7, EHP8)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP NetWeaver AS (ABAP) with SAP HANA (7.50, 7.52)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP NetWeaver AS (ABAP) with IBM Db2 (7.50, 7.52)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP NetWeaver AS (ABAP) with Oracle DB (7.50, 7.52)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP NetWeaver AS (ABAP) with SAP ASE (7.50, 7.52)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP NetWeaver AS (ABAP) with SAP MaxDB (7.50, 7.52)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP NetWeaver AS (`JAVA`) with IBM Db2 (7.50)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | -| **SAP NetWeaver AS (`JAVA`) with SAP ASE (7.50)**
single-node installation | *Coming Soon: GCP VM, OVirt VM* | +| **SAP HANA 2.0 (any version)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP S/4HANA (2021, 2022)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP S/4HANA (2020, 2021, 2022)**
single-node installation,
using SAP Maintenance Planner Stack XML
(to run SUM and SPAM / SAINT) | *Coming Soon: OVirt VM* | +| **SAP S/4HANA (1909, 2020, 2021, 2022)**
single-node System Copy installation
(Homogeneous with SAP HANA Backup / Recovery) | *Coming Soon: OVirt VM* | +| **SAP BW/4HANA (2021)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP ECC on SAP HANA (EHP7, EHP8)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP ECC on SAP HANA (EHP7, EHP8)**
single-node System Copy installation
(Homogeneous with SAP HANA Backup / Recovery) | *Coming Soon: OVirt VM* | +| **SAP ECC on IBM Db2 (EHP7, EHP8)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP ECC on Oracle DB (EHP7, EHP8)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP ECC on SAP ASE (EHP7, EHP8)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP ECC on SAP MaxDB (EHP7, EHP8)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP NetWeaver AS (ABAP) with SAP HANA (7.50, 7.52)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP NetWeaver AS (ABAP) with IBM Db2 (7.50, 7.52)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP NetWeaver AS (ABAP) with Oracle DB (7.50, 7.52)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP NetWeaver AS (ABAP) with SAP ASE (7.50, 7.52)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP NetWeaver AS (ABAP) with SAP MaxDB (7.50, 7.52)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP NetWeaver AS (`JAVA`) with IBM Db2 (7.50)**
single-node installation | *Coming Soon: OVirt VM* | +| **SAP NetWeaver AS (`JAVA`) with SAP ASE (7.50)**
single-node installation | *Coming Soon: OVirt VM* | **Key:** @@ -48,8 +55,36 @@ These Terraform Templates for SAP are designed to be: - :x: Not available yet - :no_entry_sign: Not provided by SAP +--- + +# Terraform Templates for SAP - infrastructure provisioning + +The following is an overview of the Infrastructure-as-Code (IaC) provisioning, for full details please see the underlying [Terraform Modules for SAP documentation](https://github.com/sap-linuxlab/terraform.modules_for_sap#terraform-modules-for-sap). + +| Infrastructure Platform | **Amazon Web Services (AWS)** | **Google Cloud** | **Microsoft Azure** | **IBM Cloud** | **IBM Cloud** | **IBM PowerVC** | **VMware vSphere** | +|:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:| +|   *Product* | EC2 Virtual Server | VM | VM | Virtual Server | IBM Power Virtual Server | LPAR | VM | +|

***Account Init*** | | | | | | | | +| Create Resource Group. Or re-use existing Resource Group | :x: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | N/A | N/A | +| Create Networks (VPC/VNet), Subnets, and Internet Access. Or re-use existing VPC/VNet | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | N/A | N/A | +|
***Account Bootstrap
(aka. minimal landing zone)*** | | | | | | | | +| Create Private DNS, Network Security | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | N/A | N/A | +| Create Network Interconnectivity hub | :white_check_mark: | :x: | :x: | :white_check_mark: | :white_check_mark: | N/A | N/A | +| Create TLS key pair for SSH and Import to Cloud Platform | :white_check_mark: | :x: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +|
***Bastion Injection*** | | | | | | | | +| Create Subnet and Network Security for Bastion | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | N/A | N/A | +| Create Bastion host and Public IP address | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | N/A | N/A | +|
***Host Network Access for SAP*** | | | | | | | | +| Append Network Security rules for SAP | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | N/A | N/A | +|
***Host Provision*** | | | | | | | | +| Create DNS Records (i.e. A, CNAME, PTR) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | N/A | N/A | +| Create Storage Volumes (Profile or Custom IOPS) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :warning:
no custom IOPS | :white_check_mark: | :white_check_mark: | +| Create Host/s | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | + + +--- -## Disclaimer +# Disclaimer These are common SAP solution scenarios which are codified using Infrastructure Automation for SAP (Terraform) and Build Automation for SAP (Ansible). These can be extended as needed for bespoke requirements. diff --git a/docs/DEV_INFRASTRUCTURE_GUIDANCE.md b/docs/DEV_INFRASTRUCTURE_GUIDANCE.md index 7dc97a3..65abe87 100644 --- a/docs/DEV_INFRASTRUCTURE_GUIDANCE.md +++ b/docs/DEV_INFRASTRUCTURE_GUIDANCE.md @@ -16,7 +16,7 @@ The below document contains guidance for:
-## AWS hyperscaler +## Amazon Web Services hyperscaler The Terraform Templates for SAP on Amazon Web Services are designed to be executed by an Administrator or a user with limited delegated administration privileges. @@ -41,6 +41,33 @@ aws iam attach-group-policy --group-name 'ag-terraform-exec' --policy-arn arn:aw aws iam attach-group-policy --group-name 'ag-terraform-exec' --policy-arn arn:aws:iam::aws:policy/AmazonRoute53FullAccess ``` +# Google Cloud hyperscaler + +The Terraform Templates for SAP on Google Cloud Platform are designed to be executed by an Administrator or a user with limited delegated administration privileges. + +There are options within the Terraform Templates to: +- Create VPC, or re-use existing VPC Subnet + + + +### Prior to Terraform execution + +There are a number of actions required within the Google Account prior to execution of Terraform. + +1. Google Cloud Platform places upper limit quotas for different resources, provisioning the Terraform Templates for SAP will immediately trigger these limits for `'CPUS_ALL_REGIONS'` and `'SSD_TOTAL_GB'` if using a new GCP Account and a new target GCP Region. Please check `gcloud compute regions describe us-central1 --format="table(quotas:format='table(metric,limit,usage)')"` before provisioning to a GCP Region, and manually request quota increases for these limits in the target GCP Region using instructions on https://cloud.google.com/docs/quota#requesting_higher_quota (from GCP Console or contact with GCP Support Team). + - *Please note, if using a Trial of GCP it is recommended to avoid the live chat and instead use the [Google Cloud sales specialist contact form](https://cloud.google.com/contact?direct=true) to request the quota increase for your 'individual project' GCP Trial. Otherwise you may open a discussion with the Google Sales Team chat or the Google Billing Team chat and be re-directed towards the Google Support Team chat, which requires a small payment but requires setup of a GCP Organization (and this requires a Google Cloud Identity or Google Workspace).* +2. Enable various APIs for the GCP Project, to avoid HTTP 403 errors during Terraform execution: + - Enable the Compute Engine API, using https://console.cloud.google.com/apis/api/compute.googleapis.com/overview + - Enable the Cloud DNS API, using https://console.cloud.google.com/apis/api/dns.googleapis.com/overview + - Enable the Network Connectivity API, using https://console.cloud.google.com/apis/library/networkconnectivity.googleapis.com + - Enable the Cloud Filestore API, using https://console.cloud.google.com/apis/library/file.googleapis.com + - Enable the Service Networking API (Private Services Connection to Filestore), using https://console.cloud.google.com/apis/library/servicenetworking.googleapis.com +3. Generate your GCP credentials (Client ID and Client Secret) JSON file + +### Other GCP notes + +- The provisioned host requires access to Compute Engine Red Hat Update Infrastructure (RHUI) servers on rhui.googlecloud.com (35.190.247.88) and additional Google Cloud package repositories on packages.cloud.google.com (172.217.169.78). To avoid errors with RHEL YUM, use `yum clean all && yum list all` and use `--disablerepo=*source* --disablerepo=*debug* --disablerepo=*google*` when executing. + - Some information on OS Public Images preparation can be seen here > https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/daisy_workflows/image_build/enterprise_linux ## IBM Cloud hyperscaler @@ -53,6 +80,8 @@ There are options within the Terraform Templates to: - Create Resource Group, or re-use existing Resource Group - Create IAM `(WIP)` +If re-using an existing VPC Subnet, it must be attached to a Public Gateway (PGW). This is due to Terraform design limitations which cannot detect if the PGW is missing and subsequently provision/attach. + ### Terraform execution permissions The API Key of either a User Account or Service ID will need to be assigned, by the Cloud Account Administrator, to an IAM Access Group with a minimum set of user permissons to perform these activities automatically with Terraform. diff --git a/docs/README.md b/docs/README.md index 72b1db2..6dd505f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -187,15 +187,15 @@ The following is a list of Infrastructure Platforms and Operating System vendors **Hyperscaler Cloud Service Providers, provisioned via Terraform:** - Amazon Web Services (AWS), EC2 instance (Intel Virtual Machine) -- ~~Google Cloud Platform (GCP), Compute Engine Intel Virtual Machine~~ `[after initial release]` +- Google Cloud Platform (GCP), Compute Engine Intel Virtual Machine - IBM Cloud, Intel Virtual Server - IBM Cloud, IBM Power Virtual Server - Microsoft Azure, Intel Virtual Machine **Hypervisors, provisioned via Terraform:** - IBM PowerVM LPAR -- ~~OVirt / Red Hat Virtualization Virtual Machine~~ `[after initial release]` -- ~~VMware vSphere Virtual Machine~~ `[after initial release]` +- ~~OVirt / Red Hat Virtualization Virtual Machine~~ `[planned]` +- VMware vSphere Virtual Machine **Operating Systems:** - Red Hat Enterprise Linux for SAP Solutions (RHEL4SAP) diff --git a/run_terraform.sh b/run_terraform.sh index 3b750e5..19c0cff 100755 --- a/run_terraform.sh +++ b/run_terraform.sh @@ -64,6 +64,7 @@ function sap_solution_scenario_choice() "SAP S/4HANA - Install single node (use Maintenance Planner download)" "SAP S/4HANA - System Copy single node (Homogeneous with SAP HANA Backup / Recovery)" "SAP BW/4HANA - Install single node" + "SAP ECC on HANA - Install single node" "SAP ECC on HANA - System Copy single node (Homogeneous with SAP HANA Backup / Recovery)" "SAP ECC on IBM DB2 - Install single node" "SAP ECC on Oracle DB - Install single node" @@ -107,6 +108,11 @@ function sap_solution_scenario_choice() sap_solution_scenario="sap_bw4hana_single_node_install" break ;; + "SAP ECC on HANA - Install single node") + echo ">>> Chosen option $REPLY: $opt_scenario" + sap_solution_scenario="sap_ecc_hana_single_node_install" + break + ;; "SAP ECC on HANA - System Copy single node (Homogeneous with SAP HANA Backup / Recovery)") echo ">>> Chosen option $REPLY: $opt_scenario" sap_solution_scenario="sap_ecc_hana_single_node_system_copy_homogeneous_hdb" @@ -182,13 +188,13 @@ function infrastructure_platform_choice() infrastructure_options=( "AWS - EC2 instance" -# "GCP - Compute Engine Virtual Machine" + "GCP - Compute Engine Virtual Machine" "IBM Cloud - Intel Virtual Server" "IBM Cloud - IBM Power Virtual Server" "IBM PowerVC - PHYP LPAR" "MS Azure - Virtual Machine" # "oVirt - Red Hat Virtualization (RHV)" -# "VMware vSphere - Virtual Machine" + "VMware vSphere - Virtual Machine" "Quit" ) @@ -200,11 +206,11 @@ function infrastructure_platform_choice() infrastructure_platform="aws_ec2_instance" break ;; -# "GCP - Compute Engine Virtual Machine") -# echo ">>> Chosen option $REPLY: $opt_infrastructure" -# infrastructure_platform="gcp_ce_vm" -# break -# ;; + "GCP - Compute Engine Virtual Machine") + echo ">>> Chosen option $REPLY: $opt_infrastructure" + infrastructure_platform="gcp_ce_vm" + break + ;; "IBM Cloud - Intel Virtual Server") echo ">>> Chosen option $REPLY: $opt_infrastructure" infrastructure_platform="ibmcloud_vs" @@ -230,11 +236,11 @@ function infrastructure_platform_choice() # infrastructure_platform="ovirt_rhv" # break # ;; -# "VMware vSphere - Virtual Machine") -# echo ">>> Chosen option $REPLY: $opt_infrastructure" -# infrastructure_platform="vmware" -# break -# ;; + "VMware vSphere - Virtual Machine") + echo ">>> Chosen option $REPLY: $opt_infrastructure" + infrastructure_platform="vmware_vm" + break + ;; "Quit") break ;; diff --git a/sap_bw4hana_single_node_install/aws_ec2_instance/main.tf b/sap_bw4hana_single_node_install/aws_ec2_instance/main.tf index 0323018..3a28fbb 100644 --- a/sap_bw4hana_single_node_install/aws_ec2_instance/main.tf +++ b/sap_bw4hana_single_node_install/aws_ec2_instance/main.tf @@ -107,7 +107,8 @@ module "run_host_network_access_sap_module" { module_var_aws_vpc_subnet_id = local.aws_vpc_subnet_create_boolean ? module.run_account_init_module.output_aws_vpc_subnet_id : var.aws_vpc_subnet_id module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -127,7 +128,8 @@ module "run_host_network_access_sap_public_via_proxy_module" { module_var_bastion_sg_id = module.run_bastion_inject_module.output_bastion_security_group_id module_var_bastion_connection_sg_id = module.run_bastion_inject_module.output_bastion_connection_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -231,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_bw4hana_single_node_install/aws_ec2_instance/variables.tf b/sap_bw4hana_single_node_install/aws_ec2_instance/variables.tf index 9c3e285..d82c456 100644 --- a/sap_bw4hana_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_bw4hana_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/main.tf b/sap_bw4hana_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..56faee2 --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,286 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_bw4hana_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_bw4hana_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_bw4hana_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_hana_install_master_password = var.sap_hana_install_master_password + module_var_sap_hana_install_sid = var.sap_hana_install_sid + module_var_sap_hana_install_instance_number = var.sap_hana_install_instance_number + + module_var_sap_swpm_sid = var.sap_bw4hana_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPHANADB" + module_var_sap_swpm_db_schema_abap_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_system_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_hana_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_hana_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_hana_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/outputs.tf b/sap_bw4hana_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..f047a9b --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,235 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:3$${sap_hana_instance_no}13:$target_ip:3$${sap_hana_instance_no}13 \ + -L localhost:3$${sap_hana_instance_no}15:$target_ip:3$${sap_hana_instance_no}15 \ + -L localhost:3$${sap_hana_instance_no}41:$target_ip:3$${sap_hana_instance_no}41 \ + -L localhost:443$sap_hana_instance_no:$target_ip:443$sap_hana_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no \ + -L localhost:5$${sap_hana_instance_no}13:$target_ip:5$${sap_hana_instance_no}13 \ + -L localhost:5$${sap_hana_instance_no}14:$target_ip:5$${sap_hana_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:3$${sap_hana_instance_no}13:$${target_ip}:3$${sap_hana_instance_no}13 ` + -L localhost:3$${sap_hana_instance_no}15:$${target_ip}:3$${sap_hana_instance_no}15 ` + -L localhost:3$${sap_hana_instance_no}41:$${target_ip}:3$${sap_hana_instance_no}41 ` + -L localhost:443$${sap_hana_instance_no}:$${target_ip}:443$${sap_hana_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} ` + -L localhost:5$${sap_hana_instance_no}13:$${target_ip}:5$${sap_hana_instance_no}13 ` + -L localhost:5$${sap_hana_instance_no}14:$${target_ip}:5$${sap_hana_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_bw4hana_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_bw4hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..9d596f8 --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,81 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP BW/4HANA single node install" + + type = map(any) + + default = { + + small_256gb = { + + hana01 = { + virtual_machine_profile = "n2-highmem-32" // 32 vCPU, 256GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 1 + disk_volume_type_hana_data = "pd-ssd" + disk_volume_capacity_hana_data = 384 + #disk_volume_iops_hana_data = + lvm_enable_hana_data = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_data = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_data = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_data = "xfs" + physical_partition_filesystem_block_size_hana_data = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_log = 1 + disk_volume_type_hana_log = "pd-ssd" + disk_volume_capacity_hana_log = 128 + #disk_volume_iops_hana_log = + lvm_enable_hana_log = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_log = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_log = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_log = "xfs" + physical_partition_filesystem_block_size_hana_log = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_shared = 1 + disk_volume_type_hana_shared = "pd-balanced" // Uses Burst IOPS for storage. May increase costs if there is consistent heavy usage (e.g. longer than 30mins burst, such as 200GB+ DB Backup Restore) + disk_volume_capacity_hana_shared = 320 + #disk_volume_iops_hana_shared = + lvm_enable_hana_shared = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_shared = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_shared = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_shared = "xfs" + physical_partition_filesystem_block_size_hana_shared = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 0 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 50 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = false + + disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 0 // max of 1 + #disk_volume_type_swap = "pd-standard" + #disk_volume_capacity_swap = 10 + #filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_bw4hana_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/variables.tf b/sap_bw4hana_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..3c99c5d --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,116 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_hana_install_master_password" { + description = "Ansible - SAP HANA install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_hana_install_sid" { + description = "Ansible - SAP HANA install: System ID (e.g. H01)" +} + +variable "sap_hana_install_instance_number" { + description = "Ansible - SAP HANA install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_hana_install_instance_number)) + } + +} + +variable "sap_bw4hana_install_sid" { + description = "Ansible - SAP BW/4HANA install: System ID (e.g. W01)" +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_bw4hana_2021_onehost_install" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_bw4hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..b4ff4e2 --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_256gb" + +host_os_image = "rhel-8-4-sap-ha" + +sap_hana_install_master_password = "NewPass$321" + +sap_hana_install_sid = "H01" + +sap_hana_install_instance_number = "90" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_bw4hana_install_sid = "W01" + +sap_software_download_directory = "/software" diff --git a/sap_bw4hana_single_node_install/gcp_ce_vm/versions.tf b/sap_bw4hana_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_bw4hana_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_bw4hana_single_node_install/ibmcloud_powervs/variables.tf b/sap_bw4hana_single_node_install/ibmcloud_powervs/variables.tf index 857ca64..a04590d 100644 --- a/sap_bw4hana_single_node_install/ibmcloud_powervs/variables.tf +++ b/sap_bw4hana_single_node_install/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_bw4hana_single_node_install/ibmcloud_vs/variables.tf b/sap_bw4hana_single_node_install/ibmcloud_vs/variables.tf index d47b52a..7a8f96c 100644 --- a/sap_bw4hana_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_bw4hana_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_bw4hana_single_node_install/msazure_vm/main.tf b/sap_bw4hana_single_node_install/msazure_vm/main.tf index cf9bdf8..eced592 100644 --- a/sap_bw4hana_single_node_install/msazure_vm/main.tf +++ b/sap_bw4hana_single_node_install/msazure_vm/main.tf @@ -134,6 +134,9 @@ module "run_host_network_access_sap_module" { module_var_host_security_group_name = module.run_account_bootstrap_module.output_host_security_group_name + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + } @@ -268,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_bw4hana_single_node_install/msazure_vm/variables.tf b/sap_bw4hana_single_node_install/msazure_vm/variables.tf index 3573de7..bcd7345 100644 --- a/sap_bw4hana_single_node_install/msazure_vm/variables.tf +++ b/sap_bw4hana_single_node_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_bw4hana_single_node_install/vmware_vm/variable_map_hosts.tf b/sap_bw4hana_single_node_install/vmware_vm/variable_map_hosts.tf index f44df18..7ffefb7 100644 --- a/sap_bw4hana_single_node_install/vmware_vm/variable_map_hosts.tf +++ b/sap_bw4hana_single_node_install/vmware_vm/variable_map_hosts.tf @@ -1,7 +1,7 @@ variable "map_host_specifications" { - description = "Map of host specficiations for SAP ECC on SAP HANA single node install" + description = "Map of host specficiations for SAP BW/4HANA single node install" type = map(any) @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - hana01 = { // Hostname + bwh01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 256 diff --git a/sap_ecc_hana_single_node_install/aws_ec2_instance/main.tf b/sap_ecc_hana_single_node_install/aws_ec2_instance/main.tf index c53310d..142cc3b 100644 --- a/sap_ecc_hana_single_node_install/aws_ec2_instance/main.tf +++ b/sap_ecc_hana_single_node_install/aws_ec2_instance/main.tf @@ -107,7 +107,8 @@ module "run_host_network_access_sap_module" { module_var_aws_vpc_subnet_id = local.aws_vpc_subnet_create_boolean ? module.run_account_init_module.output_aws_vpc_subnet_id : var.aws_vpc_subnet_id module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -127,7 +128,8 @@ module "run_host_network_access_sap_public_via_proxy_module" { module_var_bastion_sg_id = module.run_bastion_inject_module.output_bastion_security_group_id module_var_bastion_connection_sg_id = module.run_bastion_inject_module.output_bastion_connection_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -231,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_hana_single_node_install/aws_ec2_instance/variable_map_hosts.tf b/sap_ecc_hana_single_node_install/aws_ec2_instance/variable_map_hosts.tf index b483507..b12d292 100644 --- a/sap_ecc_hana_single_node_install/aws_ec2_instance/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_install/aws_ec2_instance/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - nw01 = { // Hostname + ecc01 = { // Hostname ec2_instance_type = "r5.8xlarge" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_hana_single_node_install/aws_ec2_instance/variables.tf b/sap_ecc_hana_single_node_install/aws_ec2_instance/variables.tf index 12d9419..3aa4e35 100644 --- a/sap_ecc_hana_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_ecc_hana_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/main.tf b/sap_ecc_hana_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..d00ceab --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,288 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_hana_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_ecc_hana_install" { + + depends_on = [ + module.run_host_provision_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_hana_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_hana_install_master_password = var.sap_hana_install_master_password + module_var_sap_hana_install_sid = var.sap_hana_install_sid + module_var_sap_hana_install_instance_number = var.sap_hana_install_instance_number + + module_var_sap_swpm_sid = var.sap_ecc_hana_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPHANADB" + module_var_sap_swpm_db_schema_abap_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_system_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_hana_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_hana_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_hana_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/outputs.tf b/sap_ecc_hana_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..f047a9b --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,235 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:3$${sap_hana_instance_no}13:$target_ip:3$${sap_hana_instance_no}13 \ + -L localhost:3$${sap_hana_instance_no}15:$target_ip:3$${sap_hana_instance_no}15 \ + -L localhost:3$${sap_hana_instance_no}41:$target_ip:3$${sap_hana_instance_no}41 \ + -L localhost:443$sap_hana_instance_no:$target_ip:443$sap_hana_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no \ + -L localhost:5$${sap_hana_instance_no}13:$target_ip:5$${sap_hana_instance_no}13 \ + -L localhost:5$${sap_hana_instance_no}14:$target_ip:5$${sap_hana_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:3$${sap_hana_instance_no}13:$${target_ip}:3$${sap_hana_instance_no}13 ` + -L localhost:3$${sap_hana_instance_no}15:$${target_ip}:3$${sap_hana_instance_no}15 ` + -L localhost:3$${sap_hana_instance_no}41:$${target_ip}:3$${sap_hana_instance_no}41 ` + -L localhost:443$${sap_hana_instance_no}:$${target_ip}:443$${sap_hana_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} ` + -L localhost:5$${sap_hana_instance_no}13:$${target_ip}:5$${sap_hana_instance_no}13 ` + -L localhost:5$${sap_hana_instance_no}14:$${target_ip}:5$${sap_hana_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..df9693d --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,81 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP ECC on SAP HANA single node install" + + type = map(any) + + default = { + + small_256gb = { + + hana01 = { + virtual_machine_profile = "n2-highmem-32" // 32 vCPU, 256GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 1 + disk_volume_type_hana_data = "pd-ssd" + disk_volume_capacity_hana_data = 384 + #disk_volume_iops_hana_data = + lvm_enable_hana_data = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_data = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_data = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_data = "xfs" + physical_partition_filesystem_block_size_hana_data = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_log = 1 + disk_volume_type_hana_log = "pd-ssd" + disk_volume_capacity_hana_log = 128 + #disk_volume_iops_hana_log = + lvm_enable_hana_log = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_log = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_log = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_log = "xfs" + physical_partition_filesystem_block_size_hana_log = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_shared = 1 + disk_volume_type_hana_shared = "pd-balanced" // Uses Burst IOPS for storage. May increase costs if there is consistent heavy usage (e.g. longer than 30mins burst, such as 200GB+ DB Backup Restore) + disk_volume_capacity_hana_shared = 320 + #disk_volume_iops_hana_shared = + lvm_enable_hana_shared = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_shared = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_shared = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_shared = "xfs" + physical_partition_filesystem_block_size_hana_shared = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 0 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 50 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = false + + disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 0 // max of 1 + #disk_volume_type_swap = "pd-standard" + #disk_volume_capacity_swap = 10 + #filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/variables.tf b/sap_ecc_hana_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..486acf7 --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,116 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_hana_install_master_password" { + description = "Ansible - SAP HANA install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_hana_install_sid" { + description = "Ansible - SAP HANA install: System ID (e.g. H01)" +} + +variable "sap_hana_install_instance_number" { + description = "Ansible - SAP HANA install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_hana_install_instance_number)) + } + +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_ecc6_ehp8_hana_onehost, sap_ecc6_ehp7_hana_onehost" +} + +variable "sap_ecc_hana_install_sid" { + description = "Ansible - SAP ECC on HANA install: System ID (e.g. E01)" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_ecc_hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..5c8bebe --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_256gb" + +host_os_image = "rhel-8-4-sap-ha" + +sap_hana_install_master_password = "NewPass$321" + +sap_hana_install_sid = "H01" + +sap_hana_install_instance_number = "90" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_ecc_hana_install_sid = "E01" + +sap_software_download_directory = "/software" diff --git a/sap_ecc_hana_single_node_install/gcp_ce_vm/versions.tf b/sap_ecc_hana_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_ecc_hana_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_ecc_hana_single_node_install/ibmcloud_powervs/variable_map_hosts.tf b/sap_ecc_hana_single_node_install/ibmcloud_powervs/variable_map_hosts.tf index efeaa6c..da14e33 100644 --- a/sap_ecc_hana_single_node_install/ibmcloud_powervs/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_install/ibmcloud_powervs/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - nw01 = { // Hostname + ecc01 = { // Hostname virtual_server_profile = "ush1-4x256" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_hana_single_node_install/ibmcloud_powervs/variables.tf b/sap_ecc_hana_single_node_install/ibmcloud_powervs/variables.tf index 9008e71..5f22822 100644 --- a/sap_ecc_hana_single_node_install/ibmcloud_powervs/variables.tf +++ b/sap_ecc_hana_single_node_install/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_hana_single_node_install/ibmcloud_vs/main.tf b/sap_ecc_hana_single_node_install/ibmcloud_vs/main.tf index 66e4707..f73083f 100644 --- a/sap_ecc_hana_single_node_install/ibmcloud_vs/main.tf +++ b/sap_ecc_hana_single_node_install/ibmcloud_vs/main.tf @@ -121,7 +121,7 @@ module "run_host_network_access_sap_module" { module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no - module_var_sap_hana_instance_no = "" + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -143,7 +143,7 @@ module "run_host_network_access_sap_public_via_proxy_module" { module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no - module_var_sap_hana_instance_no = "" + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } diff --git a/sap_ecc_hana_single_node_install/ibmcloud_vs/variable_map_hosts.tf b/sap_ecc_hana_single_node_install/ibmcloud_vs/variable_map_hosts.tf index 735b928..fea7afd 100644 --- a/sap_ecc_hana_single_node_install/ibmcloud_vs/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_install/ibmcloud_vs/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - nw01 = { // Hostname + ecc01 = { // Hostname virtual_server_profile = "mx2-32x256" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_hana_single_node_install/ibmcloud_vs/variables.tf b/sap_ecc_hana_single_node_install/ibmcloud_vs/variables.tf index 170f168..6965cf8 100644 --- a/sap_ecc_hana_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_ecc_hana_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,14 +50,14 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { - description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "host_os_image" { diff --git a/sap_ecc_hana_single_node_install/ibmpowervc/variable_map_hosts.tf b/sap_ecc_hana_single_node_install/ibmpowervc/variable_map_hosts.tf index 6747bb1..144951d 100644 --- a/sap_ecc_hana_single_node_install/ibmpowervc/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_install/ibmpowervc/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - nw01 = { // Hostname + ecc01 = { // Hostname ibmpowervc_compute_cpu_threads = 32 ibmpowervc_compute_ram_gb = 256 diff --git a/sap_ecc_hana_single_node_install/msazure_vm/main.tf b/sap_ecc_hana_single_node_install/msazure_vm/main.tf index 79cf361..61654d6 100644 --- a/sap_ecc_hana_single_node_install/msazure_vm/main.tf +++ b/sap_ecc_hana_single_node_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_hana_single_node_install/msazure_vm/variable_map_hosts.tf b/sap_ecc_hana_single_node_install/msazure_vm/variable_map_hosts.tf index 5473b40..b4ee78e 100644 --- a/sap_ecc_hana_single_node_install/msazure_vm/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_install/msazure_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - nw01 = { // Hostname + ecc01 = { // Hostname vm_instance = "Standard_M32ls" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_hana_single_node_install/msazure_vm/variables.tf b/sap_ecc_hana_single_node_install/msazure_vm/variables.tf index 469c146..0a4dad1 100644 --- a/sap_ecc_hana_single_node_install/msazure_vm/variables.tf +++ b/sap_ecc_hana_single_node_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_hana_single_node_install/vmware_vm/variable_map_hosts.tf b/sap_ecc_hana_single_node_install/vmware_vm/variable_map_hosts.tf index f44df18..55408b7 100644 --- a/sap_ecc_hana_single_node_install/vmware_vm/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_install/vmware_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - hana01 = { // Hostname + ecc01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 256 diff --git a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variable_map_hosts.tf b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variable_map_hosts.tf index 07f4071..9193c28 100644 --- a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - ecc01 = { // Hostname + ecc01 = { // Hostname virtual_server_profile = "ush1-4x256" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf index 285d38b..5b6a0ec 100644 --- a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf +++ b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variable_map_hosts.tf b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variable_map_hosts.tf index ba65cf3..6812666 100644 --- a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variable_map_hosts.tf +++ b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - ecc01 = { // Hostname + ecc01 = { // Hostname virtual_server_profile = "mx2-32x256" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf index d9e027f..f2e7dca 100644 --- a/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf +++ b/sap_ecc_hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/main.tf b/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/main.tf index 11889a0..5ee1d5f 100644 --- a/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/main.tf +++ b/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/main.tf @@ -233,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variable_map_hosts.tf b/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variable_map_hosts.tf index 273e8fb..d370480 100644 --- a/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variable_map_hosts.tf +++ b/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname ec2_instance_type = "m5.8xlarge" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variables.tf b/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variables.tf index 406bac1..112a9cc 100644 --- a/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_ecc_ibmdb2_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/main.tf b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..0d5ffa3 --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,287 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_ibmdb2_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_ecc_ibmdb2_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_ibmdb2_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_ecc_install_sid + + module_var_sap_swpm_db_schema_abap = "ABAP" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/outputs.tf b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..6873463 --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP ECC on IBM DB2 single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + ecc01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variables.tf b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..77f12e6 --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,116 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. DB2)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_anydb_install_instance_number)) + } + +} + +variable "sap_ecc_install_sid" { + description = "Ansible - SAP ECC install: System ID (e.g. E01)" +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_ecc6_ehp8_ibmdb2_onehost" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..1651d7d --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass>321" // Do not use password with $ for IBM DB2 installations + +sap_anydb_install_sid = "DB2" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_ecc_install_sid = "E01" + +sap_software_download_directory = "/software" diff --git a/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/versions.tf b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_ecc_ibmdb2_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_ecc_ibmdb2_single_node_install/ibmcloud_vs/variables.tf b/sap_ecc_ibmdb2_single_node_install/ibmcloud_vs/variables.tf index e5c0ce3..11ae5a1 100644 --- a/sap_ecc_ibmdb2_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_ecc_ibmdb2_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_ibmdb2_single_node_install/msazure_vm/main.tf b/sap_ecc_ibmdb2_single_node_install/msazure_vm/main.tf index e1596da..4113165 100644 --- a/sap_ecc_ibmdb2_single_node_install/msazure_vm/main.tf +++ b/sap_ecc_ibmdb2_single_node_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_ibmdb2_single_node_install/msazure_vm/variable_map_hosts.tf b/sap_ecc_ibmdb2_single_node_install/msazure_vm/variable_map_hosts.tf index 0930e24..cd30486 100644 --- a/sap_ecc_ibmdb2_single_node_install/msazure_vm/variable_map_hosts.tf +++ b/sap_ecc_ibmdb2_single_node_install/msazure_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname vm_instance = "Standard_D32s_v5" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_ibmdb2_single_node_install/msazure_vm/variables.tf b/sap_ecc_ibmdb2_single_node_install/msazure_vm/variables.tf index 2a1c800..b2438a9 100644 --- a/sap_ecc_ibmdb2_single_node_install/msazure_vm/variables.tf +++ b/sap_ecc_ibmdb2_single_node_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_ibmdb2_single_node_install/vmware_vm/variable_map_hosts.tf b/sap_ecc_ibmdb2_single_node_install/vmware_vm/variable_map_hosts.tf index b14d2a8..3d0e7c9 100644 --- a/sap_ecc_ibmdb2_single_node_install/vmware_vm/variable_map_hosts.tf +++ b/sap_ecc_ibmdb2_single_node_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + ecc01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables.tf b/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables.tf index 6a7eb99..25b6464 100644 --- a/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables.tf +++ b/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables_generic_for_cli.tfvars index 30a6806..2502f53 100644 --- a/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_ecc_ibmdb2_single_node_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass>321" // Do not use password with $ for IBM DB2 installations diff --git a/sap_ecc_oracledb_single_node_install/aws_ec2_instance/main.tf b/sap_ecc_oracledb_single_node_install/aws_ec2_instance/main.tf index 5122b75..44298f6 100644 --- a/sap_ecc_oracledb_single_node_install/aws_ec2_instance/main.tf +++ b/sap_ecc_oracledb_single_node_install/aws_ec2_instance/main.tf @@ -233,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variable_map_hosts.tf b/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variable_map_hosts.tf index f1995ef..24aa7b9 100644 --- a/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variable_map_hosts.tf +++ b/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname ec2_instance_type = "m5.8xlarge" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variables.tf b/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variables.tf index aa23d4d..e3c7d71 100644 --- a/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_ecc_oracledb_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/main.tf b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..c0b03c6 --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,287 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_oracledb_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_ecc_oracledb_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_oracledb_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_ecc_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPSR3" // Must be 6 characters + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/outputs.tf b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..254b266 --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP ECC on Oracle DB single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + ecc01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variables.tf b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..759da36 --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,110 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. OR1)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" +} + +variable "sap_ecc_install_sid" { + description = "Ansible - SAP ECC install: System ID (e.g. E01)" +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_ecc6_ehp8_oracledb_onehost" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..7e419f2 --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass#321" + +sap_anydb_install_sid = "OR1" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_ecc_install_sid = "E01" + +sap_software_download_directory = "/software" diff --git a/sap_ecc_oracledb_single_node_install/gcp_ce_vm/versions.tf b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_ecc_oracledb_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_ecc_oracledb_single_node_install/ibmcloud_vs/variables.tf b/sap_ecc_oracledb_single_node_install/ibmcloud_vs/variables.tf index 4065d18..d9e77bd 100644 --- a/sap_ecc_oracledb_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_ecc_oracledb_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_oracledb_single_node_install/msazure_vm/main.tf b/sap_ecc_oracledb_single_node_install/msazure_vm/main.tf index 82da7af..3fa6f9f 100644 --- a/sap_ecc_oracledb_single_node_install/msazure_vm/main.tf +++ b/sap_ecc_oracledb_single_node_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_oracledb_single_node_install/msazure_vm/variable_map_hosts.tf b/sap_ecc_oracledb_single_node_install/msazure_vm/variable_map_hosts.tf index a21ad56..7b854a8 100644 --- a/sap_ecc_oracledb_single_node_install/msazure_vm/variable_map_hosts.tf +++ b/sap_ecc_oracledb_single_node_install/msazure_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname vm_instance = "Standard_D32s_v5" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_oracledb_single_node_install/msazure_vm/variables.tf b/sap_ecc_oracledb_single_node_install/msazure_vm/variables.tf index ddd2dd4..bb966bd 100644 --- a/sap_ecc_oracledb_single_node_install/msazure_vm/variables.tf +++ b/sap_ecc_oracledb_single_node_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_oracledb_single_node_install/vmware_vm/variable_map_hosts.tf b/sap_ecc_oracledb_single_node_install/vmware_vm/variable_map_hosts.tf index 2cba239..b7c2cae 100644 --- a/sap_ecc_oracledb_single_node_install/vmware_vm/variable_map_hosts.tf +++ b/sap_ecc_oracledb_single_node_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + ecc01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_ecc_oracledb_single_node_install/vmware_vm/variables.tf b/sap_ecc_oracledb_single_node_install/vmware_vm/variables.tf index 772d9de..0f5f746 100644 --- a/sap_ecc_oracledb_single_node_install/vmware_vm/variables.tf +++ b/sap_ecc_oracledb_single_node_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_ecc_oracledb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_ecc_oracledb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars index 8f88c58..72caa20 100644 --- a/sap_ecc_oracledb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_ecc_oracledb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass#321" diff --git a/sap_ecc_sapase_single_node_install/aws_ec2_instance/main.tf b/sap_ecc_sapase_single_node_install/aws_ec2_instance/main.tf index 0a0015d..1896449 100644 --- a/sap_ecc_sapase_single_node_install/aws_ec2_instance/main.tf +++ b/sap_ecc_sapase_single_node_install/aws_ec2_instance/main.tf @@ -239,6 +239,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_volume_type_software = var.disk_volume_type_software module_var_disk_volume_capacity_software = var.disk_volume_capacity_software diff --git a/sap_ecc_sapase_single_node_install/aws_ec2_instance/variable_map_hosts.tf b/sap_ecc_sapase_single_node_install/aws_ec2_instance/variable_map_hosts.tf index ed3af09..c72322c 100644 --- a/sap_ecc_sapase_single_node_install/aws_ec2_instance/variable_map_hosts.tf +++ b/sap_ecc_sapase_single_node_install/aws_ec2_instance/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname ec2_instance_type = "m5.8xlarge" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_sapase_single_node_install/aws_ec2_instance/variables.tf b/sap_ecc_sapase_single_node_install/aws_ec2_instance/variables.tf index 36c369b..8fd5343 100644 --- a/sap_ecc_sapase_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_ecc_sapase_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/main.tf b/sap_ecc_sapase_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..947a1ba --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,287 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_sapase_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_ecc_sapase_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_sapase_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_ecc_install_sid + + module_var_sap_swpm_db_schema_abap = "ABAP" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/outputs.tf b/sap_ecc_sapase_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..cfc8f1f --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP ECC on SAP ASE 16.0 single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + ecc01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/variables.tf b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..7e633f7 --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,110 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. MX1)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" +} + +variable "sap_ecc_install_sid" { + description = "Ansible - SAP ECC install: System ID (e.g. E01)" +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_ecc6_ehp8_sapmaxdb_onehost" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..c0ababf --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass@321" + +sap_anydb_install_sid = "MX1" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_ecc_install_sid = "E01" + +sap_software_download_directory = "/software" diff --git a/sap_ecc_sapase_single_node_install/gcp_ce_vm/versions.tf b/sap_ecc_sapase_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_ecc_sapase_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_ecc_sapase_single_node_install/ibmcloud_vs/variable_map_hosts.tf b/sap_ecc_sapase_single_node_install/ibmcloud_vs/variable_map_hosts.tf index ec5ad8c..0f50907 100644 --- a/sap_ecc_sapase_single_node_install/ibmcloud_vs/variable_map_hosts.tf +++ b/sap_ecc_sapase_single_node_install/ibmcloud_vs/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - ecc01 = { // Hostname + ecc01 = { // Hostname virtual_server_profile = "bx2-32x128" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_sapase_single_node_install/ibmcloud_vs/variables.tf b/sap_ecc_sapase_single_node_install/ibmcloud_vs/variables.tf index 12b5ccc..9c1fd50 100644 --- a/sap_ecc_sapase_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_ecc_sapase_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_sapase_single_node_install/msazure_vm/main.tf b/sap_ecc_sapase_single_node_install/msazure_vm/main.tf index b520a31..82e4578 100644 --- a/sap_ecc_sapase_single_node_install/msazure_vm/main.tf +++ b/sap_ecc_sapase_single_node_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_sapase_single_node_install/msazure_vm/variable_map_hosts.tf b/sap_ecc_sapase_single_node_install/msazure_vm/variable_map_hosts.tf index b79a764..eb69b24 100644 --- a/sap_ecc_sapase_single_node_install/msazure_vm/variable_map_hosts.tf +++ b/sap_ecc_sapase_single_node_install/msazure_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname vm_instance = "Standard_D32s_v5" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_sapase_single_node_install/msazure_vm/variables.tf b/sap_ecc_sapase_single_node_install/msazure_vm/variables.tf index 21717a2..ab087e6 100644 --- a/sap_ecc_sapase_single_node_install/msazure_vm/variables.tf +++ b/sap_ecc_sapase_single_node_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_sapase_single_node_install/vmware_vm/variable_map_hosts.tf b/sap_ecc_sapase_single_node_install/vmware_vm/variable_map_hosts.tf index 66b33b0..30de51f 100644 --- a/sap_ecc_sapase_single_node_install/vmware_vm/variable_map_hosts.tf +++ b/sap_ecc_sapase_single_node_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + ecc01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_ecc_sapase_single_node_install/vmware_vm/variables.tf b/sap_ecc_sapase_single_node_install/vmware_vm/variables.tf index ca486ff..86bbd6d 100644 --- a/sap_ecc_sapase_single_node_install/vmware_vm/variables.tf +++ b/sap_ecc_sapase_single_node_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_ecc_sapase_single_node_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_ecc_sapase_single_node_install/vmware_vm/variables_generic_for_cli.tfvars index 6be0ef2..6021e34 100644 --- a/sap_ecc_sapase_single_node_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_ecc_sapase_single_node_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass@321" diff --git a/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/main.tf b/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/main.tf index db94c64..7e7c4ca 100644 --- a/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/main.tf +++ b/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/main.tf @@ -233,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variable_map_hosts.tf b/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variable_map_hosts.tf index db260bf..100f200 100644 --- a/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variable_map_hosts.tf +++ b/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname ec2_instance_type = "m5.8xlarge" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variables.tf b/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variables.tf index 36c369b..8fd5343 100644 --- a/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_ecc_sapmaxdb_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/main.tf b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..c6a96e6 --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,287 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_sapmaxdb_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_ecc_sapmaxdb_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_ecc_sapmaxdb_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_ecc_install_sid + + module_var_sap_swpm_db_schema_abap = "ABAP" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/outputs.tf b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..0f8e267 --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP ECC on SAP MaxDB single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + ecc01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variables.tf b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..7e633f7 --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,110 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. MX1)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" +} + +variable "sap_ecc_install_sid" { + description = "Ansible - SAP ECC install: System ID (e.g. E01)" +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_ecc6_ehp8_sapmaxdb_onehost" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..c0ababf --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass@321" + +sap_anydb_install_sid = "MX1" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_ecc_install_sid = "E01" + +sap_software_download_directory = "/software" diff --git a/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/versions.tf b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_ecc_sapmaxdb_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_ecc_sapmaxdb_single_node_install/ibmcloud_vs/variables.tf b/sap_ecc_sapmaxdb_single_node_install/ibmcloud_vs/variables.tf index eadcd46..da4352b 100644 --- a/sap_ecc_sapmaxdb_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_ecc_sapmaxdb_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_ecc_sapmaxdb_single_node_install/msazure_vm/main.tf b/sap_ecc_sapmaxdb_single_node_install/msazure_vm/main.tf index 1d1f68c..7902a1a 100644 --- a/sap_ecc_sapmaxdb_single_node_install/msazure_vm/main.tf +++ b/sap_ecc_sapmaxdb_single_node_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variable_map_hosts.tf b/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variable_map_hosts.tf index 5549197..9499308 100644 --- a/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variable_map_hosts.tf +++ b/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_32vcpu = { - nw01 = { // Hostname + ecc01 = { // Hostname vm_instance = "Standard_D32s_v5" // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB diff --git a/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variables.tf b/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variables.tf index d961914..fd533cc 100644 --- a/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variables.tf +++ b/sap_ecc_sapmaxdb_single_node_install/msazure_vm/variables.tf @@ -55,14 +55,14 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "host_os_image" { diff --git a/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variable_map_hosts.tf b/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variable_map_hosts.tf index 531c4aa..1bc7ca1 100644 --- a/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variable_map_hosts.tf +++ b/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + ecc01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables.tf b/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables.tf index 6852be1..dc98765 100644 --- a/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables.tf +++ b/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars index acb5db8..be321e4 100644 --- a/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_ecc_sapmaxdb_single_node_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass@321" diff --git a/sap_hana_single_node_install/aws_ec2_instance/main.tf b/sap_hana_single_node_install/aws_ec2_instance/main.tf index 3d08a81..d9805e0 100644 --- a/sap_hana_single_node_install/aws_ec2_instance/main.tf +++ b/sap_hana_single_node_install/aws_ec2_instance/main.tf @@ -229,6 +229,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_hana_single_node_install/aws_ec2_instance/variables.tf b/sap_hana_single_node_install/aws_ec2_instance/variables.tf index 0a619c0..caf3a56 100644 --- a/sap_hana_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_hana_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_hana_single_node_install/gcp_ce_vm/main.tf b/sap_hana_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..6530b34 --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,234 @@ + +module "run_account_init_module" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_hana_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_hana_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_hana_install_master_password = var.sap_hana_install_master_password + module_var_sap_hana_install_sid = var.sap_hana_install_sid + module_var_sap_hana_install_instance_number = var.sap_hana_install_instance_number + +} diff --git a/sap_hana_single_node_install/gcp_ce_vm/outputs.tf b/sap_hana_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d02f774 --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,221 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:3$${sap_hana_instance_no}13:$target_ip:3$${sap_hana_instance_no}13 \ + -L localhost:3$${sap_hana_instance_no}15:$target_ip:3$${sap_hana_instance_no}15 \ + -L localhost:3$${sap_hana_instance_no}41:$target_ip:3$${sap_hana_instance_no}41 \ + -L localhost:443$sap_hana_instance_no:$target_ip:443$sap_hana_instance_no \ + -L localhost:5$${sap_hana_instance_no}13:$target_ip:5$${sap_hana_instance_no}13 \ + -L localhost:5$${sap_hana_instance_no}14:$target_ip:5$${sap_hana_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:3$${sap_hana_instance_no}13:$${target_ip}:3$${sap_hana_instance_no}13 ` + -L localhost:3$${sap_hana_instance_no}15:$${target_ip}:3$${sap_hana_instance_no}15 ` + -L localhost:3$${sap_hana_instance_no}41:$${target_ip}:3$${sap_hana_instance_no}41 ` + -L localhost:443$${sap_hana_instance_no}:$${target_ip}:443$${sap_hana_instance_no} ` + -L localhost:5$${sap_hana_instance_no}13:$${target_ip}:5$${sap_hana_instance_no}13 ` + -L localhost:5$${sap_hana_instance_no}14:$${target_ip}:5$${sap_hana_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_hana_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_hana_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..d834ffc --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,81 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP HANA single node install" + + type = map(any) + + default = { + + small_256gb = { + + hana01 = { + virtual_machine_profile = "n2-highmem-32" // 32 vCPU, 256GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 1 + disk_volume_type_hana_data = "pd-ssd" + disk_volume_capacity_hana_data = 384 + #disk_volume_iops_hana_data = + lvm_enable_hana_data = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_data = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_data = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_data = "xfs" + physical_partition_filesystem_block_size_hana_data = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_log = 1 + disk_volume_type_hana_log = "pd-ssd" + disk_volume_capacity_hana_log = 128 + #disk_volume_iops_hana_log = + lvm_enable_hana_log = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_log = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_log = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_log = "xfs" + physical_partition_filesystem_block_size_hana_log = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_shared = 1 + disk_volume_type_hana_shared = "pd-balanced" // Uses Burst IOPS for storage. May increase costs if there is consistent heavy usage (e.g. longer than 30mins burst, such as 200GB+ DB Backup Restore) + disk_volume_capacity_hana_shared = 320 + #disk_volume_iops_hana_shared = + lvm_enable_hana_shared = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_shared = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_shared = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_shared = "xfs" + physical_partition_filesystem_block_size_hana_shared = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 0 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 50 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = false + + disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 0 // max of 1 + #disk_volume_type_swap = "pd-standard" + #disk_volume_capacity_swap = 10 + #filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_hana_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_hana_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_hana_single_node_install/gcp_ce_vm/variables.tf b/sap_hana_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..60153bf --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,88 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_hana_install_master_password" { + description = "Ansible - SAP HANA install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_hana_install_sid" { + description = "Ansible - SAP HANA install: System ID (e.g. H01)" +} + +variable "sap_hana_install_instance_number" { + description = "Ansible - SAP HANA install: Instance Number (e.g. 10)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_hana_install_instance_number)) + } + +} diff --git a/sap_hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..786f842 --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,22 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_256gb" + +host_os_image = "rhel-8-4-sap-ha" + +sap_hana_install_master_password = "NewPass$321" + +sap_hana_install_sid = "H01" + +sap_hana_install_instance_number = "90" + +sap_software_download_directory = "/software" diff --git a/sap_hana_single_node_install/gcp_ce_vm/versions.tf b/sap_hana_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_hana_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_hana_single_node_install/ibmcloud_powervs/variables.tf b/sap_hana_single_node_install/ibmcloud_powervs/variables.tf index 5bb48d5..872c8c9 100644 --- a/sap_hana_single_node_install/ibmcloud_powervs/variables.tf +++ b/sap_hana_single_node_install/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_hana_single_node_install/ibmcloud_vs/variables.tf b/sap_hana_single_node_install/ibmcloud_vs/variables.tf index 940c64b..15fa2e4 100644 --- a/sap_hana_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_hana_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_hana_single_node_install/msazure_vm/main.tf b/sap_hana_single_node_install/msazure_vm/main.tf index 5572e4e..b6f5b39 100644 --- a/sap_hana_single_node_install/msazure_vm/main.tf +++ b/sap_hana_single_node_install/msazure_vm/main.tf @@ -265,6 +265,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_hana_single_node_install/msazure_vm/variables.tf b/sap_hana_single_node_install/msazure_vm/variables.tf index 70d7fd9..529b42c 100644 --- a/sap_hana_single_node_install/msazure_vm/variables.tf +++ b/sap_hana_single_node_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_hana_install/aws_ec2_instance/main.tf b/sap_nwas_abap_hana_install/aws_ec2_instance/main.tf index 9668c8b..7abdb88 100644 --- a/sap_nwas_abap_hana_install/aws_ec2_instance/main.tf +++ b/sap_nwas_abap_hana_install/aws_ec2_instance/main.tf @@ -107,7 +107,8 @@ module "run_host_network_access_sap_module" { module_var_aws_vpc_subnet_id = local.aws_vpc_subnet_create_boolean ? module.run_account_init_module.output_aws_vpc_subnet_id : var.aws_vpc_subnet_id module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -127,7 +128,8 @@ module "run_host_network_access_sap_public_via_proxy_module" { module_var_bastion_sg_id = module.run_bastion_inject_module.output_bastion_security_group_id module_var_bastion_connection_sg_id = module.run_bastion_inject_module.output_bastion_connection_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -231,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_hana_install/aws_ec2_instance/variables.tf b/sap_nwas_abap_hana_install/aws_ec2_instance/variables.tf index efc1fdb..96d2b24 100644 --- a/sap_nwas_abap_hana_install/aws_ec2_instance/variables.tf +++ b/sap_nwas_abap_hana_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/main.tf b/sap_nwas_abap_hana_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..c9e6663 --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/main.tf @@ -0,0 +1,287 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_hana_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_nwas_abap_hana_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_hana_install?ref=main" + + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_hana_install_master_password = var.sap_hana_install_master_password + module_var_sap_hana_install_sid = var.sap_hana_install_sid + module_var_sap_hana_install_instance_number = var.sap_hana_install_instance_number + + module_var_sap_swpm_sid = var.sap_nwas_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPHANADB" + module_var_sap_swpm_db_schema_abap_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_system_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_hana_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_hana_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_hana_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/outputs.tf b/sap_nwas_abap_hana_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..f047a9b --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,235 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:3$${sap_hana_instance_no}13:$target_ip:3$${sap_hana_instance_no}13 \ + -L localhost:3$${sap_hana_instance_no}15:$target_ip:3$${sap_hana_instance_no}15 \ + -L localhost:3$${sap_hana_instance_no}41:$target_ip:3$${sap_hana_instance_no}41 \ + -L localhost:443$sap_hana_instance_no:$target_ip:443$sap_hana_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no \ + -L localhost:5$${sap_hana_instance_no}13:$target_ip:5$${sap_hana_instance_no}13 \ + -L localhost:5$${sap_hana_instance_no}14:$target_ip:5$${sap_hana_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:3$${sap_hana_instance_no}13:$${target_ip}:3$${sap_hana_instance_no}13 ` + -L localhost:3$${sap_hana_instance_no}15:$${target_ip}:3$${sap_hana_instance_no}15 ` + -L localhost:3$${sap_hana_instance_no}41:$${target_ip}:3$${sap_hana_instance_no}41 ` + -L localhost:443$${sap_hana_instance_no}:$${target_ip}:443$${sap_hana_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} ` + -L localhost:5$${sap_hana_instance_no}13:$${target_ip}:5$${sap_hana_instance_no}13 ` + -L localhost:5$${sap_hana_instance_no}14:$${target_ip}:5$${sap_hana_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/variable_locals.tf b/sap_nwas_abap_hana_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/variable_map_hosts.tf b/sap_nwas_abap_hana_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..e5c3290 --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,81 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP NetWeaver AS (ABAP) with SAP HANA single node install" + + type = map(any) + + default = { + + small_256gb = { + + hana01 = { + virtual_machine_profile = "n2-highmem-32" // 32 vCPU, 256GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 1 + disk_volume_type_hana_data = "pd-ssd" + disk_volume_capacity_hana_data = 384 + #disk_volume_iops_hana_data = + lvm_enable_hana_data = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_data = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_data = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_data = "xfs" + physical_partition_filesystem_block_size_hana_data = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_log = 1 + disk_volume_type_hana_log = "pd-ssd" + disk_volume_capacity_hana_log = 128 + #disk_volume_iops_hana_log = + lvm_enable_hana_log = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_log = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_log = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_log = "xfs" + physical_partition_filesystem_block_size_hana_log = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_shared = 1 + disk_volume_type_hana_shared = "pd-balanced" // Uses Burst IOPS for storage. May increase costs if there is consistent heavy usage (e.g. longer than 30mins burst, such as 200GB+ DB Backup Restore) + disk_volume_capacity_hana_shared = 320 + #disk_volume_iops_hana_shared = + lvm_enable_hana_shared = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_shared = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_shared = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_shared = "xfs" + physical_partition_filesystem_block_size_hana_shared = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 0 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 50 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = false + + disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 0 // max of 1 + #disk_volume_type_swap = "pd-standard" + #disk_volume_capacity_swap = 10 + #filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/variable_map_os.tf b/sap_nwas_abap_hana_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/variables.tf b/sap_nwas_abap_hana_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..24bd1cd --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/variables.tf @@ -0,0 +1,116 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_hana_install_master_password" { + description = "Ansible - SAP HANA install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_hana_install_sid" { + description = "Ansible - SAP HANA install: System ID (e.g. H01)" +} + +variable "sap_hana_install_instance_number" { + description = "Ansible - SAP HANA install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_hana_install_instance_number)) + } + +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_nwas_752_sp00_abap_hana_onehost, sap_nwas_750_sp00_abap_hana_onehost" +} + +variable "sap_nwas_install_sid" { + description = "Ansible - SAP NetWeaver AS (ABAP) install: System ID (e.g. N01)" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_hana_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..4962bd3 --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_256gb" + +host_os_image = "rhel-8-4-sap-ha" + +sap_hana_install_master_password = "NewPass$321" + +sap_hana_install_sid = "H01" + +sap_hana_install_instance_number = "90" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_nwas_install_sid = "N01" + +sap_software_download_directory = "/software" diff --git a/sap_nwas_abap_hana_install/gcp_ce_vm/versions.tf b/sap_nwas_abap_hana_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_nwas_abap_hana_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_nwas_abap_hana_install/ibmcloud_powervs/variables.tf b/sap_nwas_abap_hana_install/ibmcloud_powervs/variables.tf index 16625f8..a9a408b 100644 --- a/sap_nwas_abap_hana_install/ibmcloud_powervs/variables.tf +++ b/sap_nwas_abap_hana_install/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_hana_install/ibmcloud_vs/main.tf b/sap_nwas_abap_hana_install/ibmcloud_vs/main.tf index bc8367c..cecb0f1 100644 --- a/sap_nwas_abap_hana_install/ibmcloud_vs/main.tf +++ b/sap_nwas_abap_hana_install/ibmcloud_vs/main.tf @@ -121,7 +121,7 @@ module "run_host_network_access_sap_module" { module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no - module_var_sap_hana_instance_no = "" + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -143,7 +143,7 @@ module "run_host_network_access_sap_public_via_proxy_module" { module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no - module_var_sap_hana_instance_no = "" + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } diff --git a/sap_nwas_abap_hana_install/ibmcloud_vs/variables.tf b/sap_nwas_abap_hana_install/ibmcloud_vs/variables.tf index d11aae2..aa72060 100644 --- a/sap_nwas_abap_hana_install/ibmcloud_vs/variables.tf +++ b/sap_nwas_abap_hana_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,14 +50,14 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { - description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "host_os_image" { diff --git a/sap_nwas_abap_hana_install/msazure_vm/main.tf b/sap_nwas_abap_hana_install/msazure_vm/main.tf index 9b7cc6b..1cf9530 100644 --- a/sap_nwas_abap_hana_install/msazure_vm/main.tf +++ b/sap_nwas_abap_hana_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_hana_install/msazure_vm/variables.tf b/sap_nwas_abap_hana_install/msazure_vm/variables.tf index 4721a41..77d2f47 100644 --- a/sap_nwas_abap_hana_install/msazure_vm/variables.tf +++ b/sap_nwas_abap_hana_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_hana_install/vmware_vm/variable_map_hosts.tf b/sap_nwas_abap_hana_install/vmware_vm/variable_map_hosts.tf index bb546b4..fbb5f3f 100644 --- a/sap_nwas_abap_hana_install/vmware_vm/variable_map_hosts.tf +++ b/sap_nwas_abap_hana_install/vmware_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - hana01 = { // Hostname + nw01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 256 diff --git a/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/main.tf b/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/main.tf index 7a0618c..c58688e 100644 --- a/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/main.tf +++ b/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/main.tf @@ -233,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/variables.tf b/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/variables.tf index 153bc58..be7a14e 100644 --- a/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/variables.tf +++ b/sap_nwas_abap_ibmdb2_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/main.tf b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..d0f764b --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/main.tf @@ -0,0 +1,288 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_ibmdb2_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_nwas_abap_ibmdb2_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_ibmdb2_install?ref=main" + + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_nwas_install_sid + + module_var_sap_swpm_db_schema_abap = "ABAP" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/outputs.tf b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_locals.tf b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_map_hosts.tf b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..7ca2594 --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP NetWeaver AS (ABAP) with IBM DB2 single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + nw01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_map_os.tf b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variables.tf b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..9fb40fa --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variables.tf @@ -0,0 +1,117 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. DB2)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_anydb_install_instance_number)) + } + +} + + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_nwas_752_sp00_abap_ibmdb2_onehost, sap_nwas_750_sp00_abap_ibmdb2_onehost" +} + +variable "sap_nwas_install_sid" { + description = "Ansible - SAP NetWeaver AS (ABAP) install: System ID (e.g. N01)" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..da186f5 --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass>321" // Do not use password with $ for IBM DB2 installations + +sap_anydb_install_sid = "DB2" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_nwas_install_sid = "N01" + +sap_software_download_directory = "/software" diff --git a/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/versions.tf b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_nwas_abap_ibmdb2_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_nwas_abap_ibmdb2_install/ibmcloud_vs/variables.tf b/sap_nwas_abap_ibmdb2_install/ibmcloud_vs/variables.tf index aaf02fd..275026c 100644 --- a/sap_nwas_abap_ibmdb2_install/ibmcloud_vs/variables.tf +++ b/sap_nwas_abap_ibmdb2_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_ibmdb2_install/msazure_vm/main.tf b/sap_nwas_abap_ibmdb2_install/msazure_vm/main.tf index 7783b3a..307192f 100644 --- a/sap_nwas_abap_ibmdb2_install/msazure_vm/main.tf +++ b/sap_nwas_abap_ibmdb2_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_ibmdb2_install/msazure_vm/variables.tf b/sap_nwas_abap_ibmdb2_install/msazure_vm/variables.tf index 658459a..5b552a3 100644 --- a/sap_nwas_abap_ibmdb2_install/msazure_vm/variables.tf +++ b/sap_nwas_abap_ibmdb2_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_ibmdb2_install/vmware_vm/variable_map_hosts.tf b/sap_nwas_abap_ibmdb2_install/vmware_vm/variable_map_hosts.tf index d6dd043..e7f348d 100644 --- a/sap_nwas_abap_ibmdb2_install/vmware_vm/variable_map_hosts.tf +++ b/sap_nwas_abap_ibmdb2_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + nw01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_nwas_abap_ibmdb2_install/vmware_vm/variables.tf b/sap_nwas_abap_ibmdb2_install/vmware_vm/variables.tf index dc829df..6138de1 100644 --- a/sap_nwas_abap_ibmdb2_install/vmware_vm/variables.tf +++ b/sap_nwas_abap_ibmdb2_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_nwas_abap_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars index fa42d25..42d5002 100644 --- a/sap_nwas_abap_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_nwas_abap_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass>321" // Do not use password with $ for IBM DB2 installations diff --git a/sap_nwas_abap_oracledb_install/aws_ec2_instance/main.tf b/sap_nwas_abap_oracledb_install/aws_ec2_instance/main.tf index 06a4071..456de06 100644 --- a/sap_nwas_abap_oracledb_install/aws_ec2_instance/main.tf +++ b/sap_nwas_abap_oracledb_install/aws_ec2_instance/main.tf @@ -233,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_oracledb_install/aws_ec2_instance/variables.tf b/sap_nwas_abap_oracledb_install/aws_ec2_instance/variables.tf index c901b6f..c89a293 100644 --- a/sap_nwas_abap_oracledb_install/aws_ec2_instance/variables.tf +++ b/sap_nwas_abap_oracledb_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/main.tf b/sap_nwas_abap_oracledb_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..684ed1c --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/main.tf @@ -0,0 +1,288 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_oracledb_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_nwas_abap_oracledb_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_oracledb_install?ref=main" + + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_nwas_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPSR3" // Must be 6 characters + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/outputs.tf b/sap_nwas_abap_oracledb_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_locals.tf b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_map_hosts.tf b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..4c77f58 --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP NetWeaver (ABAP) with Oracle DB single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + nw01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_map_os.tf b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/variables.tf b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..a049a04 --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variables.tf @@ -0,0 +1,117 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. OR1)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_anydb_install_instance_number)) + } + +} + + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_nwas_752_sp00_abap_oracledb_onehost, sap_nwas_750_sp00_abap_oracledb_onehost" +} + +variable "sap_nwas_install_sid" { + description = "Ansible - SAP NetWeaver install: System ID (e.g. N01)" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..6510e15 --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass#321" + +sap_anydb_install_sid = "OR1" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_nwas_install_sid = "N01" + +sap_software_download_directory = "/software" diff --git a/sap_nwas_abap_oracledb_install/gcp_ce_vm/versions.tf b/sap_nwas_abap_oracledb_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_nwas_abap_oracledb_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_nwas_abap_oracledb_install/ibmcloud_vs/variables.tf b/sap_nwas_abap_oracledb_install/ibmcloud_vs/variables.tf index 74e8354..41e6a50 100644 --- a/sap_nwas_abap_oracledb_install/ibmcloud_vs/variables.tf +++ b/sap_nwas_abap_oracledb_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_oracledb_install/msazure_vm/main.tf b/sap_nwas_abap_oracledb_install/msazure_vm/main.tf index 1d0c982..889bed5 100644 --- a/sap_nwas_abap_oracledb_install/msazure_vm/main.tf +++ b/sap_nwas_abap_oracledb_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_oracledb_install/msazure_vm/variables.tf b/sap_nwas_abap_oracledb_install/msazure_vm/variables.tf index 6143998..68a73bb 100644 --- a/sap_nwas_abap_oracledb_install/msazure_vm/variables.tf +++ b/sap_nwas_abap_oracledb_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_oracledb_install/vmware_vm/variable_map_hosts.tf b/sap_nwas_abap_oracledb_install/vmware_vm/variable_map_hosts.tf index 795be1e..a2d83a7 100644 --- a/sap_nwas_abap_oracledb_install/vmware_vm/variable_map_hosts.tf +++ b/sap_nwas_abap_oracledb_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + nw01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_nwas_abap_oracledb_install/vmware_vm/variables.tf b/sap_nwas_abap_oracledb_install/vmware_vm/variables.tf index 26c3c96..2036335 100644 --- a/sap_nwas_abap_oracledb_install/vmware_vm/variables.tf +++ b/sap_nwas_abap_oracledb_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_nwas_abap_oracledb_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_oracledb_install/vmware_vm/variables_generic_for_cli.tfvars index 91d8c7b..604e13e 100644 --- a/sap_nwas_abap_oracledb_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_nwas_abap_oracledb_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass#321" diff --git a/sap_nwas_abap_sapase_install/aws_ec2_instance/main.tf b/sap_nwas_abap_sapase_install/aws_ec2_instance/main.tf index 5232a4d..9444e2c 100644 --- a/sap_nwas_abap_sapase_install/aws_ec2_instance/main.tf +++ b/sap_nwas_abap_sapase_install/aws_ec2_instance/main.tf @@ -233,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_sapase_install/aws_ec2_instance/variables.tf b/sap_nwas_abap_sapase_install/aws_ec2_instance/variables.tf index 153bc58..be7a14e 100644 --- a/sap_nwas_abap_sapase_install/aws_ec2_instance/variables.tf +++ b/sap_nwas_abap_sapase_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/main.tf b/sap_nwas_abap_sapase_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..d49bbeb --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/main.tf @@ -0,0 +1,288 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_sapase_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_nwas_abap_sapase_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_sapase_install?ref=main" + + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_nwas_install_sid + + module_var_sap_swpm_db_schema_abap = "ABAP" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/outputs.tf b/sap_nwas_abap_sapase_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_locals.tf b/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_map_hosts.tf b/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..141548d --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP NetWeaver AS (ABAP) with SAP ASE single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + nw01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_map_os.tf b/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/variables.tf b/sap_nwas_abap_sapase_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..9fb40fa --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/variables.tf @@ -0,0 +1,117 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. DB2)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_anydb_install_instance_number)) + } + +} + + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_nwas_752_sp00_abap_ibmdb2_onehost, sap_nwas_750_sp00_abap_ibmdb2_onehost" +} + +variable "sap_nwas_install_sid" { + description = "Ansible - SAP NetWeaver AS (ABAP) install: System ID (e.g. N01)" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_sapase_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..6788728 --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass@321" + +sap_anydb_install_sid = "AS1" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_nwas_install_sid = "N01" + +sap_software_download_directory = "/software" diff --git a/sap_nwas_abap_sapase_install/gcp_ce_vm/versions.tf b/sap_nwas_abap_sapase_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_nwas_abap_sapase_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_nwas_abap_sapase_install/ibmcloud_vs/variables.tf b/sap_nwas_abap_sapase_install/ibmcloud_vs/variables.tf index 2947173..408d370 100644 --- a/sap_nwas_abap_sapase_install/ibmcloud_vs/variables.tf +++ b/sap_nwas_abap_sapase_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_sapase_install/msazure_vm/main.tf b/sap_nwas_abap_sapase_install/msazure_vm/main.tf index 80aad40..8c0cda7 100644 --- a/sap_nwas_abap_sapase_install/msazure_vm/main.tf +++ b/sap_nwas_abap_sapase_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_sapase_install/msazure_vm/variables.tf b/sap_nwas_abap_sapase_install/msazure_vm/variables.tf index ea53e9f..e29fab8 100644 --- a/sap_nwas_abap_sapase_install/msazure_vm/variables.tf +++ b/sap_nwas_abap_sapase_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_sapase_install/vmware_vm/variable_map_hosts.tf b/sap_nwas_abap_sapase_install/vmware_vm/variable_map_hosts.tf index 611653b..1c943f9 100644 --- a/sap_nwas_abap_sapase_install/vmware_vm/variable_map_hosts.tf +++ b/sap_nwas_abap_sapase_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + nw01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_nwas_abap_sapase_install/vmware_vm/variables.tf b/sap_nwas_abap_sapase_install/vmware_vm/variables.tf index 5c4ceab..7e9206d 100644 --- a/sap_nwas_abap_sapase_install/vmware_vm/variables.tf +++ b/sap_nwas_abap_sapase_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_nwas_abap_sapase_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_sapase_install/vmware_vm/variables_generic_for_cli.tfvars index b7f5d6f..3e01625 100644 --- a/sap_nwas_abap_sapase_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_nwas_abap_sapase_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass@321" diff --git a/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/main.tf b/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/main.tf index 0078fe1..adac51c 100644 --- a/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/main.tf +++ b/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/main.tf @@ -233,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/variables.tf b/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/variables.tf index 41e02b0..21c8e6f 100644 --- a/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/variables.tf +++ b/sap_nwas_abap_sapmaxdb_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/main.tf b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..2559758 --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/main.tf @@ -0,0 +1,288 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_sapmaxdb_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_nwas_abap_sapmaxdb_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_abap_sapmaxdb_install?ref=main" + + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_nwas_install_sid + + module_var_sap_swpm_db_schema_abap = "ABAP" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/outputs.tf b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..d33b8fb --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,215 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_locals.tf b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_map_hosts.tf b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..c70eda0 --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP NetWeaver AS (ABAP) with SAP MaxDB single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + nw01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_map_os.tf b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variables.tf b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..f858d9f --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variables.tf @@ -0,0 +1,117 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass@321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. MX1)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_anydb_install_instance_number)) + } + +} + + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_nwas_752_sp00_abap_sapmaxdb_onehost, sap_nwas_750_sp00_abap_sapmaxdb_onehost" +} + +variable "sap_nwas_install_sid" { + description = "Ansible - SAP NetWeaver AS (ABAP) install: System ID (e.g. N01)" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..7814747 --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass@321" + +sap_anydb_install_sid = "MX1" + +sap_anydb_install_instance_number = "10" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_nwas_install_sid = "N01" + +sap_software_download_directory = "/software" diff --git a/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/versions.tf b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_nwas_abap_sapmaxdb_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_nwas_abap_sapmaxdb_install/ibmcloud_vs/variables.tf b/sap_nwas_abap_sapmaxdb_install/ibmcloud_vs/variables.tf index 5add2a0..63f207b 100644 --- a/sap_nwas_abap_sapmaxdb_install/ibmcloud_vs/variables.tf +++ b/sap_nwas_abap_sapmaxdb_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_sapmaxdb_install/msazure_vm/main.tf b/sap_nwas_abap_sapmaxdb_install/msazure_vm/main.tf index 8ba488c..6747f69 100644 --- a/sap_nwas_abap_sapmaxdb_install/msazure_vm/main.tf +++ b/sap_nwas_abap_sapmaxdb_install/msazure_vm/main.tf @@ -271,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_abap_sapmaxdb_install/msazure_vm/variables.tf b/sap_nwas_abap_sapmaxdb_install/msazure_vm/variables.tf index e422db6..bce577c 100644 --- a/sap_nwas_abap_sapmaxdb_install/msazure_vm/variables.tf +++ b/sap_nwas_abap_sapmaxdb_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_abap_sapmaxdb_install/vmware_vm/variable_map_hosts.tf b/sap_nwas_abap_sapmaxdb_install/vmware_vm/variable_map_hosts.tf index cc70615..93e3ae4 100644 --- a/sap_nwas_abap_sapmaxdb_install/vmware_vm/variable_map_hosts.tf +++ b/sap_nwas_abap_sapmaxdb_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + nw01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables.tf b/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables.tf index d74144d..a876782 100644 --- a/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables.tf +++ b/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables_generic_for_cli.tfvars index 2fbd54e..0f13617 100644 --- a/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_nwas_abap_sapmaxdb_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass@321" diff --git a/sap_nwas_java_ibmdb2_install/aws_ec2_instance/main.tf b/sap_nwas_java_ibmdb2_install/aws_ec2_instance/main.tf index 4ca57c2..7e33982 100644 --- a/sap_nwas_java_ibmdb2_install/aws_ec2_instance/main.tf +++ b/sap_nwas_java_ibmdb2_install/aws_ec2_instance/main.tf @@ -235,6 +235,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_java_ibmdb2_install/aws_ec2_instance/variables.tf b/sap_nwas_java_ibmdb2_install/aws_ec2_instance/variables.tf index 02d1f9f..62dc500 100644 --- a/sap_nwas_java_ibmdb2_install/aws_ec2_instance/variables.tf +++ b/sap_nwas_java_ibmdb2_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/main.tf b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..337af6a --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/main.tf @@ -0,0 +1,290 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_java_ibmdb2_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = "" + module_var_sap_nwas_java_ci_instance_no = var.sap_nwas_java_ci_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = "" + module_var_sap_nwas_java_ci_instance_no = var.sap_nwas_java_ci_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_nwas_java_ibmdb2_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_java_ibmdb2_install?ref=main" + + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_nwas_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPJAVA1" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_nwas_java_instance_nr = var.sap_nwas_java_ci_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/outputs.tf b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..0759d42 --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,211 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### HTTP/S JAVA endpoints: ####" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:5$${sap_nwas_java_ci_instance_no}00:$target_ip:5$${sap_nwas_java_ci_instance_no}01 \ + -L localhost:5$${sap_nwas_java_ci_instance_no}20:$target_ip:5$${sap_nwas_java_ci_instance_no}20 \ + -L localhost:5$${sap_nwas_java_ci_instance_no}13:$target_ip:5$${sap_nwas_java_ci_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### HTTP/S JAVA endpoints: ####" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:5$${sap_nwas_java_ci_instance_no}00:$${target_ip}:5$${sap_nwas_java_ci_instance_no}01 ` + -L localhost:5$${sap_nwas_java_ci_instance_no}20:$${target_ip}:5$${sap_nwas_java_ci_instance_no}20 ` + -L localhost:5$${sap_nwas_java_ci_instance_no}13:$${target_ip}:5$${sap_nwas_java_ci_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_locals.tf b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_map_hosts.tf b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..d9dd391 --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP NetWeaver AS (JAVA) with IBM Db2 single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + nw01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_map_os.tf b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variables.tf b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..8c782a3 --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variables.tf @@ -0,0 +1,107 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass@321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. AS1)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_anydb_install_instance_number)) + } + +} + + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_nwas_750_sp22_java_ibmdb2_onehost_ads" +} + +variable "sap_nwas_install_sid" { + description = "Ansible - SAP NetWeaver AS (ABAP) install: System ID (e.g. N01)" +} + +variable "sap_nwas_java_ci_instance_no" { + description = "Ansible - SAP NetWeaver AS (JAVA) - JAVA Central Instance (CI) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_java_ci_instance_no)) + } + +} diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..93cbba0 --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,26 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass@321" + +sap_anydb_install_sid = "DB2" + +sap_anydb_install_instance_number = "10" + +sap_nwas_install_sid = "N01" + +sap_nwas_java_ci_instance_no = "20" + +sap_software_download_directory = "/software" diff --git a/sap_nwas_java_ibmdb2_install/gcp_ce_vm/versions.tf b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_nwas_java_ibmdb2_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_nwas_java_ibmdb2_install/ibmcloud_vs/variables.tf b/sap_nwas_java_ibmdb2_install/ibmcloud_vs/variables.tf index d164925..180a79d 100644 --- a/sap_nwas_java_ibmdb2_install/ibmcloud_vs/variables.tf +++ b/sap_nwas_java_ibmdb2_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_java_ibmdb2_install/msazure_vm/main.tf b/sap_nwas_java_ibmdb2_install/msazure_vm/main.tf index e38944f..1ae7020 100644 --- a/sap_nwas_java_ibmdb2_install/msazure_vm/main.tf +++ b/sap_nwas_java_ibmdb2_install/msazure_vm/main.tf @@ -273,6 +273,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_java_ibmdb2_install/msazure_vm/variables.tf b/sap_nwas_java_ibmdb2_install/msazure_vm/variables.tf index 273a6ca..54ae05b 100644 --- a/sap_nwas_java_ibmdb2_install/msazure_vm/variables.tf +++ b/sap_nwas_java_ibmdb2_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_java_ibmdb2_install/vmware_vm/variable_map_hosts.tf b/sap_nwas_java_ibmdb2_install/vmware_vm/variable_map_hosts.tf index 874c139..bea552a 100644 --- a/sap_nwas_java_ibmdb2_install/vmware_vm/variable_map_hosts.tf +++ b/sap_nwas_java_ibmdb2_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + nw01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_nwas_java_ibmdb2_install/vmware_vm/variables.tf b/sap_nwas_java_ibmdb2_install/vmware_vm/variables.tf index e580e0b..8ca3d53 100644 --- a/sap_nwas_java_ibmdb2_install/vmware_vm/variables.tf +++ b/sap_nwas_java_ibmdb2_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_nwas_java_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_nwas_java_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars index 064506c..7688ffe 100644 --- a/sap_nwas_java_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_nwas_java_ibmdb2_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass@321" diff --git a/sap_nwas_java_sapase_install/aws_ec2_instance/main.tf b/sap_nwas_java_sapase_install/aws_ec2_instance/main.tf index 9c7be14..85b7a53 100644 --- a/sap_nwas_java_sapase_install/aws_ec2_instance/main.tf +++ b/sap_nwas_java_sapase_install/aws_ec2_instance/main.tf @@ -235,6 +235,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_java_sapase_install/aws_ec2_instance/variables.tf b/sap_nwas_java_sapase_install/aws_ec2_instance/variables.tf index 673c016..4f7d5db 100644 --- a/sap_nwas_java_sapase_install/aws_ec2_instance/variables.tf +++ b/sap_nwas_java_sapase_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/main.tf b/sap_nwas_java_sapase_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..9a8b8b0 --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/main.tf @@ -0,0 +1,290 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_java_sapase_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = "" + module_var_sap_nwas_java_ci_instance_no = var.sap_nwas_java_ci_instance_no + module_var_sap_hana_instance_no = "" + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = "" + module_var_sap_nwas_java_ci_instance_no = var.sap_nwas_java_ci_instance_no + module_var_sap_hana_instance_no = "" + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_nwas_java_ibmdb2_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_nwas_java_ibmdb2_install?ref=main" + + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_anydb_install_sid = var.sap_anydb_install_sid + module_var_sap_anydb_install_instance_number = var.sap_anydb_install_instance_number + + module_var_sap_swpm_sid = var.sap_nwas_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPJAVA1" + module_var_sap_swpm_db_schema_abap_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_system_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_anydb_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_anydb_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_nwas_java_instance_nr = var.sap_nwas_java_ci_instance_no + + module_var_sap_swpm_master_password = var.sap_anydb_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/outputs.tf b/sap_nwas_java_sapase_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..0759d42 --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,211 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### HTTP/S JAVA endpoints: ####" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:5$${sap_nwas_java_ci_instance_no}00:$target_ip:5$${sap_nwas_java_ci_instance_no}01 \ + -L localhost:5$${sap_nwas_java_ci_instance_no}20:$target_ip:5$${sap_nwas_java_ci_instance_no}20 \ + -L localhost:5$${sap_nwas_java_ci_instance_no}13:$target_ip:5$${sap_nwas_java_ci_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### HTTP/S JAVA endpoints: ####" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:5$${sap_nwas_java_ci_instance_no}00:$${target_ip}:5$${sap_nwas_java_ci_instance_no}01 ` + -L localhost:5$${sap_nwas_java_ci_instance_no}20:$${target_ip}:5$${sap_nwas_java_ci_instance_no}20 ` + -L localhost:5$${sap_nwas_java_ci_instance_no}13:$${target_ip}:5$${sap_nwas_java_ci_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/variable_locals.tf b/sap_nwas_java_sapase_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/variable_map_hosts.tf b/sap_nwas_java_sapase_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..f878d1e --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,51 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP NetWeaver AS (JAVA) with SAP ASE single node install" + + type = map(any) + + default = { + + small_32vcpu = { + + nw01 = { // Hostname + virtual_machine_profile = "n2-standard-32" // 32 vCPU, 128GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 0 + + disk_volume_count_hana_log = 0 + + disk_volume_count_hana_shared = 0 + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 1 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 56 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = true + + #disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 1 // max of 1 + disk_volume_type_swap = "pd-standard" + disk_volume_capacity_swap = 96 + filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/variable_map_os.tf b/sap_nwas_java_sapase_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/variables.tf b/sap_nwas_java_sapase_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..23719c6 --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/variables.tf @@ -0,0 +1,107 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_anydb_install_master_password" { + description = "Ansible - SAP AnyDB install: set common initial password (e.g. NewPass@321)" +} + +variable "sap_anydb_install_sid" { + description = "Ansible - SAP AnyDB install: System ID (e.g. AS1)" +} + +variable "sap_anydb_install_instance_number" { + description = "Ansible - SAP AnyDB install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_anydb_install_instance_number)) + } + +} + + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_nwas_750_sp22_java_sapase_onehost_ads" +} + +variable "sap_nwas_install_sid" { + description = "Ansible - SAP NetWeaver AS (ABAP) install: System ID (e.g. N01)" +} + +variable "sap_nwas_java_ci_instance_no" { + description = "Ansible - SAP NetWeaver AS (JAVA) - JAVA Central Instance (CI) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_java_ci_instance_no)) + } + +} diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_nwas_java_sapase_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..441d835 --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,26 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_32vcpu" + +host_os_image = "rhel-8-4-sap-ha" + +sap_anydb_install_master_password = "NewPass@321" + +sap_anydb_install_sid = "AS1" + +sap_anydb_install_instance_number = "10" + +sap_nwas_install_sid = "N01" + +sap_nwas_java_ci_instance_no = "20" + +sap_software_download_directory = "/software" diff --git a/sap_nwas_java_sapase_install/gcp_ce_vm/versions.tf b/sap_nwas_java_sapase_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_nwas_java_sapase_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_nwas_java_sapase_install/ibmcloud_vs/variables.tf b/sap_nwas_java_sapase_install/ibmcloud_vs/variables.tf index 218697c..eb5efa0 100644 --- a/sap_nwas_java_sapase_install/ibmcloud_vs/variables.tf +++ b/sap_nwas_java_sapase_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_java_sapase_install/msazure_vm/main.tf b/sap_nwas_java_sapase_install/msazure_vm/main.tf index ed8dacd..40d55cf 100644 --- a/sap_nwas_java_sapase_install/msazure_vm/main.tf +++ b/sap_nwas_java_sapase_install/msazure_vm/main.tf @@ -273,6 +273,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_nwas_java_sapase_install/msazure_vm/variables.tf b/sap_nwas_java_sapase_install/msazure_vm/variables.tf index 074a8a2..ea80a7e 100644 --- a/sap_nwas_java_sapase_install/msazure_vm/variables.tf +++ b/sap_nwas_java_sapase_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_nwas_java_sapase_install/vmware_vm/variable_map_hosts.tf b/sap_nwas_java_sapase_install/vmware_vm/variable_map_hosts.tf index a65993a..1833e40 100644 --- a/sap_nwas_java_sapase_install/vmware_vm/variable_map_hosts.tf +++ b/sap_nwas_java_sapase_install/vmware_vm/variable_map_hosts.tf @@ -7,9 +7,9 @@ variable "map_host_specifications" { default = { - small_256gb = { + small_32vcpu = { - hana01 = { // Hostname + nw01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 128 diff --git a/sap_nwas_java_sapase_install/vmware_vm/variables.tf b/sap_nwas_java_sapase_install/vmware_vm/variables.tf index 5d2071c..69b52e1 100644 --- a/sap_nwas_java_sapase_install/vmware_vm/variables.tf +++ b/sap_nwas_java_sapase_install/vmware_vm/variables.tf @@ -39,7 +39,7 @@ variable "bastion_ssh_port" { } variable "host_specification_plan" { - description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." + description = "Host specification plans are small_32vcpu. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." } variable "os_vendor_account_user" { diff --git a/sap_nwas_java_sapase_install/vmware_vm/variables_generic_for_cli.tfvars b/sap_nwas_java_sapase_install/vmware_vm/variables_generic_for_cli.tfvars index d03d7b3..1d712b5 100644 --- a/sap_nwas_java_sapase_install/vmware_vm/variables_generic_for_cli.tfvars +++ b/sap_nwas_java_sapase_install/vmware_vm/variables_generic_for_cli.tfvars @@ -4,7 +4,7 @@ dns_root_domain = "poc.cloud" bastion_user = false -host_specification_plan = "small_256gb" +host_specification_plan = "small_32vcpu" sap_anydb_install_master_password = "NewPass@321" diff --git a/sap_s4hana_single_node_install/aws_ec2_instance/main.tf b/sap_s4hana_single_node_install/aws_ec2_instance/main.tf index d3603f7..6ca7850 100644 --- a/sap_s4hana_single_node_install/aws_ec2_instance/main.tf +++ b/sap_s4hana_single_node_install/aws_ec2_instance/main.tf @@ -107,7 +107,8 @@ module "run_host_network_access_sap_module" { module_var_aws_vpc_subnet_id = local.aws_vpc_subnet_create_boolean ? module.run_account_init_module.output_aws_vpc_subnet_id : var.aws_vpc_subnet_id module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -127,7 +128,8 @@ module "run_host_network_access_sap_public_via_proxy_module" { module_var_bastion_sg_id = module.run_bastion_inject_module.output_bastion_security_group_id module_var_bastion_connection_sg_id = module.run_bastion_inject_module.output_bastion_connection_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -231,6 +233,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_s4hana_single_node_install/aws_ec2_instance/variables.tf b/sap_s4hana_single_node_install/aws_ec2_instance/variables.tf index 3e5666c..6893e1e 100644 --- a/sap_s4hana_single_node_install/aws_ec2_instance/variables.tf +++ b/sap_s4hana_single_node_install/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/main.tf b/sap_s4hana_single_node_install/gcp_ce_vm/main.tf new file mode 100644 index 0000000..eb40a22 --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/main.tf @@ -0,0 +1,286 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_s4hana_install?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_s4hana_install" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_s4hana_install?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_hana_install_master_password = var.sap_hana_install_master_password + module_var_sap_hana_install_sid = var.sap_hana_install_sid + module_var_sap_hana_install_instance_number = var.sap_hana_install_instance_number + + module_var_sap_swpm_sid = var.sap_s4hana_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPHANADB" + module_var_sap_swpm_db_schema_abap_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_system_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_hana_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_hana_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_hana_install_master_password + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/outputs.tf b/sap_s4hana_single_node_install/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..f047a9b --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/outputs.tf @@ -0,0 +1,235 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:3$${sap_hana_instance_no}13:$target_ip:3$${sap_hana_instance_no}13 \ + -L localhost:3$${sap_hana_instance_no}15:$target_ip:3$${sap_hana_instance_no}15 \ + -L localhost:3$${sap_hana_instance_no}41:$target_ip:3$${sap_hana_instance_no}41 \ + -L localhost:443$sap_hana_instance_no:$target_ip:443$sap_hana_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no \ + -L localhost:5$${sap_hana_instance_no}13:$target_ip:5$${sap_hana_instance_no}13 \ + -L localhost:5$${sap_hana_instance_no}14:$target_ip:5$${sap_hana_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:3$${sap_hana_instance_no}13:$${target_ip}:3$${sap_hana_instance_no}13 ` + -L localhost:3$${sap_hana_instance_no}15:$${target_ip}:3$${sap_hana_instance_no}15 ` + -L localhost:3$${sap_hana_instance_no}41:$${target_ip}:3$${sap_hana_instance_no}41 ` + -L localhost:443$${sap_hana_instance_no}:$${target_ip}:443$${sap_hana_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} ` + -L localhost:5$${sap_hana_instance_no}13:$${target_ip}:5$${sap_hana_instance_no}13 ` + -L localhost:5$${sap_hana_instance_no}14:$${target_ip}:5$${sap_hana_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/variable_locals.tf b/sap_s4hana_single_node_install/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf b/sap_s4hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..77bafd8 --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,81 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP S/4HANA single node install" + + type = map(any) + + default = { + + small_256gb = { + + hana01 = { + virtual_machine_profile = "n2-highmem-32" // 32 vCPU, 256GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 1 + disk_volume_type_hana_data = "pd-ssd" + disk_volume_capacity_hana_data = 384 + #disk_volume_iops_hana_data = + lvm_enable_hana_data = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_data = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_data = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_data = "xfs" + physical_partition_filesystem_block_size_hana_data = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_log = 1 + disk_volume_type_hana_log = "pd-ssd" + disk_volume_capacity_hana_log = 128 + #disk_volume_iops_hana_log = + lvm_enable_hana_log = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_log = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_log = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_log = "xfs" + physical_partition_filesystem_block_size_hana_log = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_shared = 1 + disk_volume_type_hana_shared = "pd-balanced" // Uses Burst IOPS for storage. May increase costs if there is consistent heavy usage (e.g. longer than 30mins burst, such as 200GB+ DB Backup Restore) + disk_volume_capacity_hana_shared = 320 + #disk_volume_iops_hana_shared = + lvm_enable_hana_shared = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_shared = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_shared = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_shared = "xfs" + physical_partition_filesystem_block_size_hana_shared = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 0 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 50 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = false + + disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 0 // max of 1 + #disk_volume_type_swap = "pd-standard" + #disk_volume_capacity_swap = 10 + #filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/variable_map_os.tf b/sap_s4hana_single_node_install/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/variables.tf b/sap_s4hana_single_node_install/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..b08b860 --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/variables.tf @@ -0,0 +1,116 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_hana_install_master_password" { + description = "Ansible - SAP HANA install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_hana_install_sid" { + description = "Ansible - SAP HANA install: System ID (e.g. H01)" +} + +variable "sap_hana_install_instance_number" { + description = "Ansible - SAP HANA install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_hana_install_instance_number)) + } + +} + +variable "sap_s4hana_install_sid" { + description = "Ansible - SAP S/4HANA install: System ID (e.g. S01)" +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_s4hana_2021_onehost_install, sap_s4hana_2022_onehost_install" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_s4hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..80544ca --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_256gb" + +host_os_image = "rhel-8-4-sap-ha" + +sap_hana_install_master_password = "NewPass$321" + +sap_hana_install_sid = "H01" + +sap_hana_install_instance_number = "90" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_s4hana_install_sid = "S01" + +sap_software_download_directory = "/software" diff --git a/sap_s4hana_single_node_install/gcp_ce_vm/versions.tf b/sap_s4hana_single_node_install/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_s4hana_single_node_install/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_s4hana_single_node_install/ibmcloud_powervs/variables.tf b/sap_s4hana_single_node_install/ibmcloud_powervs/variables.tf index eda52d9..56e4f2f 100644 --- a/sap_s4hana_single_node_install/ibmcloud_powervs/variables.tf +++ b/sap_s4hana_single_node_install/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name , or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install/ibmcloud_vs/variables.tf b/sap_s4hana_single_node_install/ibmcloud_vs/variables.tf index 219a12e..4278c89 100644 --- a/sap_s4hana_single_node_install/ibmcloud_vs/variables.tf +++ b/sap_s4hana_single_node_install/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install/msazure_vm/main.tf b/sap_s4hana_single_node_install/msazure_vm/main.tf index 06067c7..28bc7a7 100644 --- a/sap_s4hana_single_node_install/msazure_vm/main.tf +++ b/sap_s4hana_single_node_install/msazure_vm/main.tf @@ -134,6 +134,9 @@ module "run_host_network_access_sap_module" { module_var_host_security_group_name = module.run_account_bootstrap_module.output_host_security_group_name + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + } @@ -268,6 +271,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_s4hana_single_node_install/msazure_vm/variables.tf b/sap_s4hana_single_node_install/msazure_vm/variables.tf index 7a19102..3d17481 100644 --- a/sap_s4hana_single_node_install/msazure_vm/variables.tf +++ b/sap_s4hana_single_node_install/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install/vmware_vm/variable_map_hosts.tf b/sap_s4hana_single_node_install/vmware_vm/variable_map_hosts.tf index 8d65673..2d558ce 100644 --- a/sap_s4hana_single_node_install/vmware_vm/variable_map_hosts.tf +++ b/sap_s4hana_single_node_install/vmware_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - hana01 = { // Hostname + s4h01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 256 diff --git a/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/main.tf b/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/main.tf index b01c2b5..b73e430 100644 --- a/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/main.tf +++ b/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/main.tf @@ -108,7 +108,8 @@ module "run_host_network_access_sap_module" { module_var_aws_vpc_subnet_id = local.aws_vpc_subnet_create_boolean ? module.run_account_init_module.output_aws_vpc_subnet_id : var.aws_vpc_subnet_id module_var_host_security_group_id = module.run_account_bootstrap_module.output_host_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -128,7 +129,8 @@ module "run_host_network_access_sap_public_via_proxy_module" { module_var_bastion_sg_id = module.run_bastion_inject_module.output_bastion_security_group_id module_var_bastion_connection_sg_id = module.run_bastion_inject_module.output_bastion_connection_security_group_id - module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number } @@ -232,6 +234,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/variables.tf b/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/variables.tf index a6c4cb2..1f8b601 100644 --- a/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/variables.tf +++ b/sap_s4hana_single_node_install_maintenance_plan/aws_ec2_instance/variables.tf @@ -35,10 +35,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/main.tf b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/main.tf new file mode 100644 index 0000000..07462c5 --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/main.tf @@ -0,0 +1,289 @@ + +module "run_ansible_dry_run" { + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_s4hana_install_maintplan?ref=main" + + module_var_dry_run_test = "x86_64" // x86_64 or ppc64le + + # Terraform Module Variables which are mandatory, all with an empty string + module_var_bastion_boolean = false + module_var_bastion_user = "" + module_var_bastion_ssh_port = 0 + module_var_bastion_private_ssh_key = "" + module_var_bastion_floating_ip = "" + module_var_host_private_ssh_key = "" + module_var_host_private_ip = "" + module_var_hostname = "software_media_dry_run" + module_var_dns_root_domain_name = "" + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + module_var_sap_swpm_sid = "" + module_var_sap_swpm_db_schema_abap = "" + module_var_sap_swpm_db_schema_abap_password = "" + module_var_sap_swpm_ddic_000_password = "" + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + module_var_sap_maintenance_planner_transaction_name = var.sap_maintenance_planner_transaction_name + +} + + +module "run_account_init_module" { + + depends_on = [ + module.run_ansible_dry_run + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_init?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_vpc_subnet_create_boolean = local.google_cloud_vpc_subnet_create_boolean + module_var_gcp_vpc_subnet_name = local.google_cloud_vpc_subnet_create_boolean ? 0 : var.google_cloud_vpc_subnet_name + +} + + +module "run_account_bootstrap_module" { + + depends_on = [ + module.run_account_init_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/account_bootstrap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + +} + + +module "run_bastion_inject_module" { + + depends_on = [ + module.run_account_bootstrap_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/bastion_inject?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region = local.google_cloud_region + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_os_image = var.map_os_image_regex[var.bastion_os_image] + + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_public_ssh_key = module.run_account_bootstrap_module.output_bastion_public_ssh_key + +} + + +module "run_host_network_access_sap_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + +} + + +module "run_host_network_access_sap_public_via_proxy_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_network_access_sap_public_via_proxy?ref=main" + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + + module_var_bastion_subnet_name = module.run_bastion_inject_module.output_bastion_subnet_name + +} + + +module "run_host_provision_module" { + + depends_on = [ + module.run_bastion_inject_module + ] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//gcp_ce_vm/host_provision?ref=main" + + + module_var_resource_prefix = var.resource_prefix + + module_var_gcp_region_zone = var.google_cloud_region_zone + module_var_gcp_vpc_subnet_name = module.run_account_init_module.output_vpc_subnet_name + + module_var_dns_root_domain_name = var.dns_root_domain + module_var_dns_zone_name = module.run_account_bootstrap_module.output_dns_zone_name + + module_var_host_os_image = var.map_os_image_regex[var.host_os_image] + + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_user = var.bastion_user + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + module_var_bastion_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_ssh_public_key = module.run_account_bootstrap_module.output_host_public_ssh_key + module_var_host_ssh_private_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable with nested objects + + for_each = toset([ + for key, value in var.map_host_specifications[var.host_specification_plan] : key + ]) + + module_var_virtual_machine_hostname = each.key + + module_var_virtual_machine_profile = var.map_host_specifications[var.host_specification_plan][each.key].virtual_machine_profile + + module_var_disk_volume_count_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data + module_var_disk_volume_type_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data + module_var_disk_volume_capacity_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_data + module_var_disk_volume_iops_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_data == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_data : null + module_var_lvm_enable_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data + module_var_lvm_pv_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_data : 0 + module_var_lvm_vg_data_alignment_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_data : 0 + module_var_lvm_vg_physical_extent_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_data : 0 + module_var_lvm_lv_stripe_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_data : 0 + module_var_filesystem_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_data + module_var_physical_partition_filesystem_block_size_hana_data = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_data == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_data ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_data + + module_var_disk_volume_count_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log + module_var_disk_volume_type_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log + module_var_disk_volume_capacity_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_log + module_var_disk_volume_iops_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_log == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_log : null + module_var_lvm_enable_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log + module_var_lvm_pv_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_log : 0 + module_var_lvm_vg_data_alignment_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_log : 0 + module_var_lvm_vg_physical_extent_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_log : 0 + module_var_lvm_lv_stripe_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_log : 0 + module_var_filesystem_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_log + module_var_physical_partition_filesystem_block_size_hana_log = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_log == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_log ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_log + + module_var_disk_volume_count_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared + module_var_disk_volume_type_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared + module_var_disk_volume_capacity_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_hana_shared + module_var_disk_volume_iops_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_hana_shared == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_hana_shared : null + module_var_lvm_enable_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared + module_var_lvm_pv_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_hana_shared : 0 + module_var_lvm_vg_data_alignment_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_hana_shared : 0 + module_var_lvm_vg_physical_extent_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_hana_shared : 0 + module_var_lvm_lv_stripe_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_hana_shared : 0 + module_var_filesystem_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_hana_shared + module_var_physical_partition_filesystem_block_size_hana_shared = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_hana_shared == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_hana_shared ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_hana_shared + + module_var_disk_volume_count_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb + module_var_disk_volume_type_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb + module_var_disk_volume_capacity_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_anydb + module_var_disk_volume_iops_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_anydb == "custom" ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_iops_anydb : null + module_var_lvm_enable_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? false : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb + module_var_lvm_pv_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_pv_data_alignment_anydb : 0 + module_var_lvm_vg_data_alignment_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_data_alignment_anydb : 0 + module_var_lvm_vg_physical_extent_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_vg_physical_extent_size_anydb : 0 + module_var_lvm_lv_stripe_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? var.map_host_specifications[var.host_specification_plan][each.key].lvm_lv_stripe_size_anydb : 0 + module_var_filesystem_mount_path_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_mount_path_anydb + module_var_filesystem_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].filesystem_anydb + module_var_physical_partition_filesystem_block_size_anydb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_anydb == 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].lvm_enable_anydb ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].physical_partition_filesystem_block_size_anydb + + module_var_disk_volume_count_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_usr_sap + module_var_disk_volume_type_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_usr_sap + module_var_disk_volume_capacity_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_usr_sap + module_var_filesystem_usr_sap = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_usr_sap + + module_var_disk_volume_count_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_sapmnt + module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt + module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt + module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation + + module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb + module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap + module_var_disk_volume_type_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_swap : 0 + module_var_disk_volume_capacity_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_swap : 0 + module_var_filesystem_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? var.map_host_specifications[var.host_specification_plan][each.key].filesystem_swap : 0 + + module_var_disk_volume_type_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_software + module_var_disk_volume_capacity_software = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_software + module_var_sap_software_download_directory = var.sap_software_download_directory + +} + + +module "run_ansible_sap_s4hana_install_maintplan" { + + depends_on = [module.run_host_provision_module] + + source = "github.com/sap-linuxlab/terraform.modules_for_sap//all/ansible_sap_s4hana_install_maintplan?ref=main" + + # Terraform Module Variables using the prior Terraform Module Variables (from bootstrap module) + module_var_bastion_boolean = true // required as true boolean for any Cloud Service Provider (CSP) + module_var_bastion_user = var.bastion_user + module_var_bastion_ssh_port = var.bastion_ssh_port + module_var_bastion_private_ssh_key = module.run_account_bootstrap_module.output_bastion_private_ssh_key + + module_var_bastion_floating_ip = module.run_bastion_inject_module.output_bastion_ip + + module_var_host_private_ssh_key = module.run_account_bootstrap_module.output_host_private_ssh_key + + + # Set Terraform Module Variables using for_each loop on a map Terraform Variable at runtime + + for_each = module.run_host_provision_module + module_var_host_private_ip = join(", ", each.value.*.output_host_private_ip) + module_var_hostname = join(", ", each.value.*.output_host_name) + module_var_dns_root_domain_name = var.dns_root_domain + + module_var_sap_id_user = var.sap_id_user + module_var_sap_id_user_password = var.sap_id_user_password + + module_var_sap_hana_install_master_password = var.sap_hana_install_master_password + module_var_sap_hana_install_sid = var.sap_hana_install_sid + module_var_sap_hana_install_instance_number = var.sap_hana_install_instance_number + + module_var_sap_swpm_sid = var.sap_s4hana_install_sid + + module_var_sap_swpm_db_schema_abap = "SAPHANADB" + module_var_sap_swpm_db_schema_abap_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_system_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_systemdb_password = var.sap_hana_install_master_password + module_var_sap_swpm_db_sidadm_password = var.sap_hana_install_master_password + module_var_sap_swpm_ddic_000_password = var.sap_hana_install_master_password + module_var_sap_swpm_pas_instance_nr = var.sap_nwas_abap_pas_instance_no + module_var_sap_swpm_ascs_instance_nr = var.sap_nwas_abap_ascs_instance_no + + module_var_sap_swpm_master_password = var.sap_hana_install_master_password + + module_var_sap_maintenance_planner_transaction_name = var.sap_maintenance_planner_transaction_name + + module_var_sap_swpm_template_selected = var.sap_swpm_template_selected + + module_var_sap_software_download_directory = var.sap_software_download_directory + +} diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/outputs.tf b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/outputs.tf new file mode 100644 index 0000000..f047a9b --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/outputs.tf @@ -0,0 +1,235 @@ + +############################################################## +# Export SSH key to file on local +############################################################## + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "bastion_rsa" { + content = module.run_account_bootstrap_module.output_bastion_private_ssh_key + filename = "${path.root}/ssh/bastion_rsa" + file_permission = "0400" +} + +# Use path object to store key files temporarily in root of execution - https://www.terraform.io/docs/language/expressions/references.html#filesystem-and-workspace-info +resource "local_file" "hosts_rsa" { + content = module.run_account_bootstrap_module.output_host_private_ssh_key + filename = "${path.root}/ssh/hosts_rsa" + file_permission = "0400" +} + + +output "ssh_sap_connection_details" { + value = local.is_wsl ? "IGNORE" : <>> Chosen option $REPLY: $opt" + select opt_ip in "$${target_host_array[@]}"; do + if [ $opt_ip = "Quit" ]; then break 2; fi + target_ip=$opt_ip + echo "---- Selected option $REPLY, tunneling into $target_ip ----" + break + done + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N \ + $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file \ + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -L localhost:32$sap_nwas_abap_pas_instance_no:$target_ip:32$sap_nwas_abap_pas_instance_no \ + -L localhost:33$sap_nwas_abap_pas_instance_no:$target_ip:33$sap_nwas_abap_pas_instance_no \ + -L localhost:3$${sap_hana_instance_no}13:$target_ip:3$${sap_hana_instance_no}13 \ + -L localhost:3$${sap_hana_instance_no}15:$target_ip:3$${sap_hana_instance_no}15 \ + -L localhost:3$${sap_hana_instance_no}41:$target_ip:3$${sap_hana_instance_no}41 \ + -L localhost:443$sap_hana_instance_no:$target_ip:443$sap_hana_instance_no \ + -L localhost:443$sap_nwas_abap_pas_instance_no:$target_ip:443$sap_nwas_abap_pas_instance_no \ + -L localhost:5$${sap_hana_instance_no}13:$target_ip:5$${sap_hana_instance_no}13 \ + -L localhost:5$${sap_hana_instance_no}14:$target_ip:5$${sap_hana_instance_no}14 + break + ;; + "OS root access, via SSH stdin/stdout forwarding proxy") + echo ">>> Chosen option $REPLY: $opt" + select opt_ssh in "$${target_host_array[@]}"; do + if [ $opt_ssh = "Quit" ]; then break 2; fi + target_ip=$opt_ssh + echo "---- Selected option $REPLY, logging into $target_ip ----" + break + done + + if [ -n "$target_ip" ]; then + ssh -i $target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \ + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $bastion_private_key_file -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + fi + break + ;; + "Quit") + break + ;; + *) echo "Invalid option $REPLY" ;; + esac + done +} + +# Then call shell function and select which target +sshjump + +EOF +} + + +# If detected Windows WSL2, then find the installed name using external resource to return a JSON string +data "external" "wsl_distro_name" { + count = local.is_wsl ? 1 : 0 + program = ["bash", "-c", "echo \"{\\\"stdout\\\":\\\"$(echo $WSL_DISTRO_NAME)\\\"}\""] +} + +output "ssh_sap_connection_details_windows" { + value = local.not_wsl ? "IGNORE" : <>> Chosen option $(PSItem)" + echo "" + echo "#### For SAP HANA Studio, use Add System with host name as localhost; do not add port numbers." + echo "#### If selecting 'Connect using SSL' on Connection Properties, then on Additional Properties (final) screen deselect 'Validate the SSL certificate'" + echo "" + echo "#### For SAPGUI, use expert mode SAP Logon String as: ####" + echo "conn=/H/localhost/S/32$sap_nwas_abap_pas_instance_no&expert=true" + echo "" + # SSH port forward binding, using -L local_host:local_port:remote_host:remote_port (add -vv for debugging) + ssh -N ` + $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -L localhost:32$${sap_nwas_abap_pas_instance_no}:$${target_ip}:32$${sap_nwas_abap_pas_instance_no} ` + -L localhost:33$${sap_nwas_abap_pas_instance_no}:$${target_ip}:33$${sap_nwas_abap_pas_instance_no} ` + -L localhost:3$${sap_hana_instance_no}13:$${target_ip}:3$${sap_hana_instance_no}13 ` + -L localhost:3$${sap_hana_instance_no}15:$${target_ip}:3$${sap_hana_instance_no}15 ` + -L localhost:3$${sap_hana_instance_no}41:$${target_ip}:3$${sap_hana_instance_no}41 ` + -L localhost:443$${sap_hana_instance_no}:$${target_ip}:443$${sap_hana_instance_no} ` + -L localhost:443$${sap_nwas_abap_pas_instance_no}:$${target_ip}:443$${sap_nwas_abap_pas_instance_no} ` + -L localhost:5$${sap_hana_instance_no}13:$${target_ip}:5$${sap_hana_instance_no}13 ` + -L localhost:5$${sap_hana_instance_no}14:$${target_ip}:5$${sap_hana_instance_no}14 + } + } + 2 { + foreach ($target_host in $target_host_array) { + $i=$target_host_array.IndexOf($target_host) + echo "$i) $target_host" + } + $target_host_selection = Read-Host "Please make a selection" + if ($target_host_array[$target_host_selection] -eq "Quit" ){ + break + }else { + $target_ip = $target_host_array[$target_host_selection] + #echo ">>> Chosen option $(PSItem)" + ssh -i $temp_target_private_key_file root@$target_ip -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ` + -o ProxyCommand="ssh -W %h:%p $bastion_user@$bastion_host -p $bastion_port -i $temp_bastion_private_key_file ` + -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" + } + } + 3 { + break + } + } +} + +EOF + +} diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_locals.tf b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_locals.tf new file mode 100644 index 0000000..8f30669 --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_locals.tf @@ -0,0 +1,19 @@ +locals { + + google_cloud_vpc_subnet_create_boolean = var.google_cloud_vpc_subnet_name == "new" ? true : false + + google_cloud_region = replace(var.google_cloud_region_zone, "/-[^-]*$/", "") + + # Directories start with "C:..." on Windows; All other OSs use "/" for root. + detect_windows = substr(pathexpand("~"), 0, 1) == "/" ? false : true + detect_shell = substr(pathexpand("~"), 0, 1) == "/" ? true : false + + # Used for displaying Shell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + not_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? false : true : true + + # Used for displaying Windows PowerShell ssh connection output + # /proc/version contains WSL subsstring, if detected then running Windows Subsystem for Linux + is_wsl = fileexists("/proc/version") ? length(regexall("WSL", file("/proc/version"))) > 0 ? true : false : false + +} diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_map_hosts.tf b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_map_hosts.tf new file mode 100644 index 0000000..77bafd8 --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_map_hosts.tf @@ -0,0 +1,81 @@ + +variable "map_host_specifications" { + + description = "Map of host specficiations for SAP S/4HANA single node install" + + type = map(any) + + default = { + + small_256gb = { + + hana01 = { + virtual_machine_profile = "n2-highmem-32" // 32 vCPU, 256GB Memory + + // N.B. all capacities must be different from each other, due to Shell loop searching based on capacity GB + + disk_volume_count_hana_data = 1 + disk_volume_type_hana_data = "pd-ssd" + disk_volume_capacity_hana_data = 384 + #disk_volume_iops_hana_data = + lvm_enable_hana_data = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_data = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_data = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_data = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_data = "xfs" + physical_partition_filesystem_block_size_hana_data = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_log = 1 + disk_volume_type_hana_log = "pd-ssd" + disk_volume_capacity_hana_log = 128 + #disk_volume_iops_hana_log = + lvm_enable_hana_log = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_log = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_log = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_log = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_log = "xfs" + physical_partition_filesystem_block_size_hana_log = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_hana_shared = 1 + disk_volume_type_hana_shared = "pd-balanced" // Uses Burst IOPS for storage. May increase costs if there is consistent heavy usage (e.g. longer than 30mins burst, such as 200GB+ DB Backup Restore) + disk_volume_capacity_hana_shared = 320 + #disk_volume_iops_hana_shared = + lvm_enable_hana_shared = false // if false, then disk volume count should be 1 + #lvm_pv_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM PV Physical Extent. + #lvm_vg_data_alignment_hana_shared = "1M" //default 1MiB offset from disk start before first LVM VG Physical Extent. + #lvm_vg_physical_extent_size_hana_shared = "4M" //default 4MiB, difficult to change once set. Akin to Physical Block Size. + #lvm_lv_stripe_size_hana_shared = "64K" //default 64KiB. Akin to Virtualized Block Size. + filesystem_hana_shared = "xfs" + physical_partition_filesystem_block_size_hana_shared = "4k" // only if LVM is set to false; if XFS then only 4k value allowed otherwise will be overridden (see README about XFS and Page Size) + + disk_volume_count_anydb = 0 + + disk_volume_count_usr_sap = 0 // max of 1 + disk_volume_type_usr_sap = "pd-standard" + disk_volume_capacity_usr_sap = 64 + filesystem_usr_sap = "xfs" + + disk_volume_count_sapmnt = 0 // max of 1 + disk_volume_type_sapmnt = "pd-standard" + disk_volume_capacity_sapmnt = 50 + filesystem_sapmnt = "xfs" + nfs_boolean_sapmnt = false + + disk_swapfile_size_gb = 2 // not required if disk volume set + disk_volume_count_swap = 0 // max of 1 + #disk_volume_type_swap = "pd-standard" + #disk_volume_capacity_swap = 10 + #filesystem_swap = "xfs" + + disk_volume_type_software = "pd-standard" + disk_volume_capacity_software = 100 + } + + } + + } + +} + diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_map_os.tf b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_map_os.tf new file mode 100644 index 0000000..954ecd3 --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variable_map_os.tf @@ -0,0 +1,79 @@ + +# There is no Terraform Resource for data lookup of all GCP OS Images, therefore the input does not use wildcard + +variable "map_os_image_regex" { + + description = "Map of operating systems OS Image, static OS Image names, to identify latest OS Image for the OS major.minor version" + + type = map(any) + + default = { + + rhel-8-latest = { + project = "rhel-cloud" + family = "rhel-8" + }, + + rhel-7-7-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-7-sap-ha" + }, + + rhel-7-9-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-7-9-sap-ha" + }, + + rhel-8-1-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-1-sap-ha" + }, + + rhel-8-2-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-2-sap-ha" + }, + + rhel-8-4-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-4-sap-ha" + }, + + rhel-8-6-sap-ha = { + project = "rhel-sap-cloud" + family = "rhel-8-6-sap-ha" + }, + + sles-15-latest = { + project = "suse-cloud" + family = "sles-15" + }, + + sles-12-sp5-sap = { + project = "suse-sap-cloud" + family = "sles-12-sp5-sap" + }, + + sles-15-sp1-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp1-sap" + }, + + sles-15-sp2-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp2-sap" + }, + + sles-15-sp3-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp3-sap" + }, + + sles-15-sp4-sap = { + project = "suse-sap-cloud" + family = "sles-15-sp4-sap" + }, + + } + +} diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variables.tf b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variables.tf new file mode 100644 index 0000000..372437d --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variables.tf @@ -0,0 +1,120 @@ + +variable "google_cloud_project" { + description = "Target GCP Project ID" +} + +variable "google_cloud_region_zone" { + description = "Target GCP Zone, the GCP Region will be calculated from this value (e.g. europe-west9-a)" +} + +variable "google_cloud_credentials_json" { + description = "Enter path to GCP Key File for Service Account (or Google Application Default Credentials JSON file for GCloud CLI)" +} + +variable "google_cloud_vpc_subnet_name" { + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC" +} + +variable "resource_prefix" { + description = "Prefix to resource names" +} + +variable "dns_root_domain" { + description = "Root Domain for Private DNS used with the Virtual Machine" +} + +variable "bastion_os_image" { + description = "Bastion OS Image. This variable uses the locals mapping with regex of OS Images, and will alter bastion provisioning." +} + +variable "bastion_user" { + description = "OS User to create on Bastion host to avoid pass-through root user (e.g. bastionuser)" +} + +variable "bastion_ssh_port" { + type = number + description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" + + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } +} + +variable "host_specification_plan" { + description = "Host specification plans are small_256gb. This variable uses the locals mapping with a nested list of host specifications, and will alter host provisioning." +} + +variable "host_os_image" { + description = "Host OS Image. This variable uses the locals mapping with regex of OS Images, and will alter host provisioning." +} + +variable "sap_software_download_directory" { + description = "Mount point for downloads of SAP Software" + + validation { + error_message = "Directory must start with forward slash." + condition = can(regex("^/", var.sap_software_download_directory)) + } + +} + + + +variable "sap_id_user" { + description = "Ansible - Please enter your SAP ID user (e.g. S-User)" +} + +variable "sap_id_user_password" { + description = "Ansible - Please enter your SAP ID password" +} + +variable "sap_hana_install_master_password" { + description = "Ansible - SAP HANA install: set common initial password (e.g. NewPass$321)" +} + +variable "sap_hana_install_sid" { + description = "Ansible - SAP HANA install: System ID (e.g. H01)" +} + +variable "sap_hana_install_instance_number" { + description = "Ansible - SAP HANA install: Instance Number (e.g. 90)" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_hana_install_instance_number)) + } + +} + +variable "sap_s4hana_install_sid" { + description = "Ansible - SAP S/4HANA install: System ID (e.g. S01)" +} + +variable "sap_maintenance_planner_transaction_name" { + description = "Ansible - SAP Maintenance Planner Transaction name for SAP S/4HANA, required to perform download of this stack" +} + +variable "sap_swpm_template_selected" { + description = "Ansible - Select template to use: sap_s4hana_2020_onehost_install, sap_s4hana_2021_onehost_install, sap_s4hana_2022_onehost_install" +} + +variable "sap_nwas_abap_ascs_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - ABAP Central Services (ASCS) instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_ascs_instance_no)) + } + +} + +variable "sap_nwas_abap_pas_instance_no" { + description = "Ansible - SAP NetWeaver AS (ABAP) - Primary Application Server instance number" + + validation { + error_message = "Cannot use Instance Number 43 (HA port number) or 89 (Windows Remote Desktop Services)." + condition = !can(regex("(43|89)", var.sap_nwas_abap_pas_instance_no)) + } + +} diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variables_generic_for_cli.tfvars b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variables_generic_for_cli.tfvars new file mode 100644 index 0000000..80544ca --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/variables_generic_for_cli.tfvars @@ -0,0 +1,28 @@ + +resource_prefix = "sap" + +dns_root_domain = "poc.cloud" + +bastion_os_image = "rhel-8-latest" + +bastion_user = "bastionuser" + +bastion_ssh_port = 50222 + +host_specification_plan = "small_256gb" + +host_os_image = "rhel-8-4-sap-ha" + +sap_hana_install_master_password = "NewPass$321" + +sap_hana_install_sid = "H01" + +sap_hana_install_instance_number = "90" + +sap_nwas_abap_ascs_instance_no = "01" + +sap_nwas_abap_pas_instance_no = "00" + +sap_s4hana_install_sid = "S01" + +sap_software_download_directory = "/software" diff --git a/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/versions.tf b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/versions.tf new file mode 100644 index 0000000..346ab78 --- /dev/null +++ b/sap_s4hana_single_node_install_maintenance_plan/gcp_ce_vm/versions.tf @@ -0,0 +1,34 @@ +# Terraform declaration + +terraform { + required_version = ">= 1.0" + required_providers { + google = { + #source = "localdomain/provider/google" // Local, on macOS path to place files would be $HOME/.terraform.d/plugins/localdomain/provider/google/1.xx.xx/darwin_amd6 + source = "hashicorp/google" // Terraform Registry + version = ">=4.50.0" + } + } +} + +# Terraform Provider declaration +# +# Nested provider configurations cannot be used with depends_on meta-argument between modules +# +# The calling module block can use either: +# - "providers" argument in the module block +# - none, inherit default (un-aliased) provider configuration +# +# Therefore the below is blank and is only for reference if this module needs to be executed manually + + +# Terraform Provider declaration + +provider "google" { + project = var.google_cloud_project + region = local.google_cloud_region + zone = var.google_cloud_region_zone + + credentials = var.google_cloud_credentials_json + +} diff --git a/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_powervs/variables.tf b/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_powervs/variables.tf index b661ae4..73017f3 100644 --- a/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_powervs/variables.tf +++ b/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_vs/variables.tf b/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_vs/variables.tf index b124197..cdb560a 100644 --- a/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_vs/variables.tf +++ b/sap_s4hana_single_node_install_maintenance_plan/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/main.tf b/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/main.tf index e0cdd75..d370481 100644 --- a/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/main.tf +++ b/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/main.tf @@ -135,6 +135,9 @@ module "run_host_network_access_sap_module" { module_var_host_security_group_name = module.run_account_bootstrap_module.output_host_security_group_name + module_var_sap_nwas_abap_pas_instance_no = var.sap_nwas_abap_pas_instance_no + module_var_sap_hana_instance_no = var.sap_hana_install_instance_number + } @@ -269,6 +272,8 @@ module "run_host_provision_module" { module_var_disk_volume_type_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_type_sapmnt module_var_disk_volume_capacity_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_capacity_sapmnt module_var_filesystem_sapmnt = var.map_host_specifications[var.host_specification_plan][each.key].filesystem_sapmnt + module_var_nfs_boolean_sapmnt = false // always false, single node installation + module_var_nfs_fqdn_sapmnt = "" // always false, single node installation module_var_disk_swapfile_size_gb = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap > 0 ? 0 : var.map_host_specifications[var.host_specification_plan][each.key].disk_swapfile_size_gb module_var_disk_volume_count_swap = var.map_host_specifications[var.host_specification_plan][each.key].disk_volume_count_swap diff --git a/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/variables.tf b/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/variables.tf index 7a19102..3d17481 100644 --- a/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/variables.tf +++ b/sap_s4hana_single_node_install_maintenance_plan/msazure_vm/variables.tf @@ -55,10 +55,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_install_maintenance_plan/vmware_vm/variable_map_hosts.tf b/sap_s4hana_single_node_install_maintenance_plan/vmware_vm/variable_map_hosts.tf index 8d65673..2d558ce 100644 --- a/sap_s4hana_single_node_install_maintenance_plan/vmware_vm/variable_map_hosts.tf +++ b/sap_s4hana_single_node_install_maintenance_plan/vmware_vm/variable_map_hosts.tf @@ -9,7 +9,7 @@ variable "map_host_specifications" { small_256gb = { - hana01 = { // Hostname + s4h01 = { // Hostname vmware_vm_compute_cpu_threads = 32 vmware_vm_compute_ram_gb = 256 diff --git a/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf b/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf index b1abda5..267315e 100644 --- a/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf +++ b/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_powervs/variables.tf @@ -25,7 +25,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +44,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" { diff --git a/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf b/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf index 6dc6d38..b486104 100644 --- a/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf +++ b/sap_s4hana_single_node_system_copy_homogeneous_hdb/ibmcloud_vs/variables.tf @@ -18,6 +18,12 @@ variable "ibmcloud_resource_group" { variable "ibmcloud_vpc_availability_zone" { description = "Target IBM Cloud Availability Zone (the IBM Cloud Region will be calculated from this value)" + + validation { + error_message = "Please enter an IBM Cloud Availability Zone (e.g. us-south-1)." + condition = can(regex("^([a-zA-Z0-9]*-[a-zA-Z0-9]*){2}$", var.ibmcloud_vpc_availability_zone)) + } + } variable "ibmcloud_iam_yesno" { @@ -25,7 +31,7 @@ variable "ibmcloud_iam_yesno" { } variable "ibmcloud_vpc_subnet_name" { - description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range" + description = "Enter existing/target VPC Subnet name, or enter 'new' to create a VPC with a default VPC Address Prefix Range. If using an existing VPC Subnet, it must be attached to a Public Gateway (i.e. SNAT)" } variable "dns_root_domain" { @@ -44,10 +50,10 @@ variable "bastion_ssh_port" { type = number description = "Bastion host SSH Port from IANA Dynamic Ports range (49152 to 65535)" - #validation { - # condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 - # error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." - #} + validation { + condition = var.bastion_ssh_port > 49152 && var.bastion_ssh_port < 65535 + error_message = "Bastion host SSH Port must fall within IANA Dynamic Ports range (49152 to 65535)." + } } variable "host_specification_plan" {