Skip to content

Commit

Permalink
Harmonize Terraform across different CSP (#267)
Browse files Browse the repository at this point in the history
* Remove predeployment module

Remove a no more used module used to generate ssh keys.

* Align Terraform across different CSP

Align README and example, more salt removing.
Order variables in similar order across modules and providers.
Align inventory tremplate.
Align terraform variable descriptions.
Improve the .gitignore to better ignore venv and logs.
  • Loading branch information
mpagot authored Sep 3, 2024
1 parent acd16c6 commit 4c9524f
Show file tree
Hide file tree
Showing 30 changed files with 143 additions and 240 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
**/.venv/
**/.venv*/
**/__pycache__/
**/.hypo*/
**/BUILD*/
secret/
terraform/**/inventory.yaml
terraform/**/.terraform
Expand All @@ -15,8 +17,7 @@ ansible/playbooks/roles/sap_storage
ansible/playbooks/vars/hana_media.yaml
ansible/playbooks/vars/azure_hana_media.yaml
ansible/playbooks/vars/hana_vars.yaml
terraform.apply.log
terraform.init.log
terraform.plan.log
*.log
*.log.txt
settings.json
variables.sh
25 changes: 13 additions & 12 deletions terraform/aws/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AWS Public Cloud deployment with Terraform and Salt
# AWS Public Cloud deployment with Terraform and Ansible

* [Quickstart](#quickstart)
* [High level description](#high-level-description)
Expand All @@ -18,7 +18,8 @@ provider? See [Getting started](../README.md#getting-started)

## Quickstart

This is a very short guide. For detailed information see [Using SUSE Automation to Deploy an SAP HANA Cluster on AWS - Getting Started🔗](https://documentation.suse.com/sbp/all/single-html/TRD-SLES-SAP-HA-automation-quickstart-cloud-aws/).
This is a very short guide. For detailed information see
[Using SUSE Automation to Deploy an SAP HANA Cluster on AWS - Getting Started🔗](https://documentation.suse.com/sbp/all/single-html/TRD-SLES-SAP-HA-automation-quickstart-cloud-aws/).

For detailed information and deployment options have a look at `terraform.tfvars.example`.

Expand All @@ -34,14 +35,12 @@ For detailed information and deployment options have a look at `terraform.tfvars

2) **Generate private and public keys for the cluster nodes without specifying the passphrase:**

Alternatively, you can set the `pre_deployment` variable to automatically create the cluster ssh keys.

``` shell
mkdir -p ../salt/sshkeys
ssh-keygen -f ../salt/sshkeys/cluster.id_rsa -q -P ""
mkdir -p ../sshkeys
ssh-keygen -f ../sshkeys/cluster.id_rsa -q -P ""
```

The key files need to have same name as defined in [terraform.tfvars](terraform.tfvars.example).
The key files need to have same name as defined in [terraform.tfvars](./terraform.tfvars.example).

3) **Configure API access to AWS**

Expand Down Expand Up @@ -130,12 +129,12 @@ For detailed information and deployment options have a look at `terraform.tfvars

**Warning: If you use the 2nd option, the AWS web panel won't show that the created instances have any role attached, but they have. The limits in the IAM access makes this not visible, that's all.**

4) **Deploy**:
4) **Deploy**

``` shell
terraform init
terraform workspace new my-execution # optional
terraform workspace select my-execution # optional
terraform workspace new myexecution # optional
terraform workspace select myexecution # optional
terraform plan
terraform apply
```
Expand All @@ -148,7 +147,7 @@ For detailed information and deployment options have a look at `terraform.tfvars

## High level description

The terraform configuration creates the infrastructure needed for the installation of an SAP HANA cluster in System Replication mode, combined with the high-availability capabilities provided by the SUSE Linux Enterprise Server for SAP Applications in *AWS*.
This Terraform configuration files in this directory can be used to create the infrastructure required to install a SAP HanaSR cluster in System Replication mode, combined with the high-availability capabilities provided by the SUSE Linux Enterprise Server for SAP Applications in *AWS*.

![High level description](../doc/highlevel_description_aws.png)

Expand All @@ -167,7 +166,9 @@ Internally to the subnet, all traffic is allowed.
* shared EFS file systems
* SSH key pairs

By default it creates 3 instances in AWS: one for support services (mainly iSCSI as most other services - DHCP, NTP, etc - are provided by Amazon) and 2 cluster nodes, but this can be changed to deploy more cluster nodes as needed.
By default, this configuration creates 3 instances in AWS: one for support services (mainly iSCSI as most other services - DHCP, NTP, etc - are provided by Amazon) and 2 cluster nodes, but this can be changed to deploy more cluster nodes as needed.

Once the infrastructure is created by Terraform, the servers are provisioned with Ansible.

## Customization

Expand Down
20 changes: 10 additions & 10 deletions terraform/aws/infrastructure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ resource "aws_vpc" "vpc" {
enable_dns_support = true

tags = {
Name = "${local.deployment_name}-vpc"
Workspace = local.deployment_name
name = "${local.deployment_name}-vpc"
workspace = local.deployment_name
}
}

Expand All @@ -62,8 +62,8 @@ resource "aws_internet_gateway" "igw" {
vpc_id = local.vpc_id

tags = {
Name = "${local.deployment_name}-igw"
Workspace = local.deployment_name
name = "${local.deployment_name}-igw"
workspace = local.deployment_name
}
}

Expand All @@ -73,17 +73,17 @@ resource "aws_subnet" "infra-subnet" {
availability_zone = element(data.aws_availability_zones.available.names, 0)

tags = {
Name = "${local.deployment_name}-infra-subnet"
Workspace = local.deployment_name
name = "${local.deployment_name}-infra-subnet"
workspace = local.deployment_name
}
}

resource "aws_route_table" "route-table" {
vpc_id = local.vpc_id

tags = {
Name = "${local.deployment_name}-hana-route-table"
Workspace = local.deployment_name
name = "${local.deployment_name}-hana-route-table"
workspace = local.deployment_name
}
}

Expand All @@ -109,8 +109,8 @@ resource "aws_security_group" "secgroup" {
vpc_id = local.vpc_id

tags = {
Name = "${local.deployment_name}-sg"
Workspace = local.deployment_name
name = "${local.deployment_name}-sg"
workspace = local.deployment_name
}
}

Expand Down
5 changes: 0 additions & 5 deletions terraform/aws/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
module "local_execution" {
source = "../generic_modules/local_exec"
enabled = var.pre_deployment
}

# This locals entry is used to store the IP addresses of all the machines.
# Autogenerated addresses example based in 10.0.0.0/16
# Iscsi server: 10.0.0.4
Expand Down
8 changes: 4 additions & 4 deletions terraform/aws/modules/drbd_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ resource "aws_subnet" "drbd-subnet" {
availability_zone = element(var.availability_zones, count.index)

tags = {
Name = "${var.common_variables["deployment_name"]}-drbd-subnet-${count.index + 1}"
Workspace = var.common_variables["deployment_name"]
name = "${var.common_variables["deployment_name"]}-drbd-subnet-${count.index + 1}"
workspace = var.common_variables["deployment_name"]
}
}

Expand Down Expand Up @@ -64,8 +64,8 @@ resource "aws_instance" "drbd" {
}

tags = {
Name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
Workspace = var.common_variables["deployment_name"]
name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
workspace = var.common_variables["deployment_name"]
"${var.common_variables["deployment_name"]}-cluster" = "${var.name}${format("%02d", count.index + 1)}"
}
}
30 changes: 15 additions & 15 deletions terraform/aws/modules/drbd_node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ variable "name" {
type = string
}

variable "network_domain" {
description = "hostname's network domain"
type = string
}

variable "drbd_count" {
description = "Number of drbd machines to create the cluster"
type = number
Expand All @@ -23,6 +18,21 @@ variable "vm_size" {
type = string
}

variable "os_image" {
description = "sles4sap AMI image identifier or a pattern used to find the image name (e.g. suse-sles-sap-15-sp1-byos)"
type = string
}

variable "os_owner" {
description = "OS image owner"
type = string
}

variable "network_domain" {
description = "hostname's network domain"
type = string
}

variable "availability_zones" {
description = "Used availability zones"
type = list(string)
Expand Down Expand Up @@ -89,16 +99,6 @@ variable "iscsi_srv_ip" {
type = string
}

variable "os_image" {
description = "sles4sap AMI image identifier or a pattern used to find the image name (e.g. suse-sles-sap-15-sp1-byos)"
type = string
}

variable "os_owner" {
description = "OS image owner"
type = string
}

variable "nfs_mounting_point" {
description = "Mounting point of the NFS share created in to of DRBD (`/mnt` must not be used in Azure)"
type = string
Expand Down
8 changes: 4 additions & 4 deletions terraform/aws/modules/hana_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ resource "aws_subnet" "hana-subnet" {
availability_zone = element(var.availability_zones, count.index)

tags = {
Name = "${var.common_variables["deployment_name"]}-hana-subnet-${count.index + 1}"
Workspace = var.common_variables["deployment_name"]
name = "${var.common_variables["deployment_name"]}-hana-subnet-${count.index + 1}"
workspace = var.common_variables["deployment_name"]
}
}

Expand Down Expand Up @@ -85,8 +85,8 @@ resource "aws_instance" "hana" {
#}

tags = {
Name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
Workspace = var.common_variables["deployment_name"]
name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
workspace = var.common_variables["deployment_name"]
"${local.hana_stonith_tag}" = "${var.name}${format("%02d", count.index + 1)}"
}
}
20 changes: 10 additions & 10 deletions terraform/aws/modules/hana_node/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ variable "vm_size" {
type = string
}

variable "os_image" {
description = "sles4sap AMI image identifier or a pattern used to find the image name (e.g. suse-sles-sap-15-sp1-byos)"
type = string
}

variable "os_owner" {
description = "OS image owner"
type = string
}

variable "availability_zones" {
description = "Used availability zones"
type = list(string)
Expand Down Expand Up @@ -143,13 +153,3 @@ variable "reg_code" {
description = "If informed, register the product using SUSEConnect"
default = ""
}

variable "os_image" {
description = "sles4sap AMI image identifier or a pattern used to find the image name (e.g. suse-sles-sap-15-sp1-byos)"
type = string
}

variable "os_owner" {
description = "OS image owner"
type = string
}
4 changes: 2 additions & 2 deletions terraform/aws/modules/iscsi_server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "aws_instance" "iscsisrv" {
}

tags = {
Name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
Workspace = var.common_variables["deployment_name"]
name = "${var.common_variables["deployment_name"]}-${var.name}${format("%02d", count.index + 1)}"
workspace = var.common_variables["deployment_name"]
}
}
30 changes: 15 additions & 15 deletions terraform/aws/modules/iscsi_server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,26 @@ variable "subnet_ids" {
type = list(string)
}

variable "os_image" {
description = "sles4sap AMI image identifier or a pattern used to find the image name (e.g. suse-sles-sap-15-sp1-byos)"
type = string
}

variable "os_owner" {
description = "OS image owner"
type = string
}

variable "name" {
description = "hostname, without the domain part"
type = string
}

variable "vm_size" {
description = "The instance type of iscsi server node."
type = string
}

variable "network_domain" {
description = "hostname's network domain"
type = string
Expand All @@ -27,11 +42,6 @@ variable "iscsi_count" {
type = number
}

variable "vm_size" {
description = "The instance type of iscsi server node."
type = string
}

variable "key_name" {
description = "AWS key pair name"
type = string
Expand All @@ -58,13 +68,3 @@ variable "lun_count" {
type = number
default = 3
}

variable "os_image" {
description = "sles4sap AMI image identifier or a pattern used to find the image name (e.g. suse-sles-sap-15-sp1-byos)"
type = string
}

variable "os_owner" {
description = "OS image owner"
type = string
}
4 changes: 2 additions & 2 deletions terraform/aws/modules/monitoring/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resource "aws_instance" "monitoring" {
}

tags = {
Name = "${var.common_variables["deployment_name"]}-${var.name}"
Workspace = var.common_variables["deployment_name"]
name = "${var.common_variables["deployment_name"]}-${var.name}"
workspace = var.common_variables["deployment_name"]
}
}
11 changes: 5 additions & 6 deletions terraform/aws/modules/monitoring/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ variable "name" {
type = string
}

variable "monitoring_enabled" {
description = "enable the host to be monitored by exporters, e.g node_exporter"
type = bool
default = false
}

variable "vm_size" {
description = "The instance type of monitoring node."
type = string
}

variable "monitoring_enabled" {
description = "enable the host to be monitored by exporters, e.g node_exporter"
type = bool
default = false
}

variable "network_domain" {
description = "hostname's network domain"
Expand Down
4 changes: 2 additions & 2 deletions terraform/aws/modules/netweaver_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ resource "aws_subnet" "netweaver-subnet" {
cidr_block = element(var.subnet_address_range, count.index)
availability_zone = element(var.availability_zones, count.index)
tags = {
Name = "${var.common_variables["deployment_name"]}-netweaver-subnet-${count.index + 1}"
Workspace = var.common_variables["deployment_name"]
name = "${var.common_variables["deployment_name"]}-netweaver-subnet-${count.index + 1}"
workspace = var.common_variables["deployment_name"]
}
}

Expand Down
Loading

0 comments on commit 4c9524f

Please sign in to comment.