Skip to content

Terraform module to create a set of SAP HANA databases virtual machines on VMware on OVHcloud.

License

Notifications You must be signed in to change notification settings

ovh/terraform-vsphere-sap-hana-database

Repository files navigation

OVHcloud SAP HANA databases Terraform module

Terraform module to create a set of SAP HANA databases virtual machines on VMware on OVHcloud. You have the possibility to create many SAP HANA databases virtual machines with different parameters.

vSphere user requirements

User in the vSphere client with the following permissions:

  • vSphere access: Read/Write
  • Access to the VM Network: Operator
  • Access to the V(X)LANs: Operator

How to use this module

This repository has an example folder which includes several ways to use this module.

Requirements

Name Version
terraform >= 1.5.5
vsphere >= 2.4.1

Providers

Name Version
vsphere 2.4.1

Resources

Name Type
vsphere_compute_cluster_host_group.cluster_host_group resource
vsphere_compute_cluster_vm_anti_affinity_rule.sap_hana_database_anti_affinity_rule resource
vsphere_compute_cluster_vm_group.cluster_sap_hana_database_group resource
vsphere_compute_cluster_vm_host_rule.cluster_vm_host_rule resource
vsphere_virtual_machine.sap_hana_database resource
vsphere_compute_cluster.cluster data source
vsphere_content_library.library data source
vsphere_content_library_item.item data source
vsphere_datacenter.datacenter data source
vsphere_datastore.custom_datastore_disks data source
vsphere_datastore.datastore data source
vsphere_datastore.default_datastore_disks data source
vsphere_datastore.iso_datastore data source
vsphere_host.host data source
vsphere_network.network data source
vsphere_storage_policy.custom_datastore_disks data source
vsphere_storage_policy.default_datastore_disks data source

Inputs

Name Description Type Default Required
sap_hana_database_datastore Name of the datastore to store SAP HANA databases virtual machines string n/a yes
sap_hana_databases List of SAP HANA databases virtual machines wanted with these parameters (mandatory, even if empty).

Example
[
 {
   "name" = "hana1",
   "model" = "M",
   "cpus" = "",
   "cpus_per_socket" = "48",
   "memory" = "",
   "custom_disks" = false,
   "scsi_controller_count" = "",
   "disks" = [],
   "networks" = ["VLAN20"],
   "guest_id" = "sles15_64Guest",
   "vsphere_content_library" = "",
   "template" = "",
   "iso_datastore" = "",
   "iso_path" = "",
   "vapp_options" = {}
 },
 {
   "name" = "hana2",
   "model" = "S",
   "cpus" = "",
   "cpus_per_socket" = "24",
   "memory" = "",
   "custom_disks" = false,
   "scsi_controller_count" = "",
   "disks" = [],
   "networks" = ["VLAN20"],
   "guest_id" = "sles15_64Guest",
   "vsphere_content_library" = "",
   "template" = "",
   "iso_datastore" = "",
   "iso_path" = "",
   "vapp_options" = {}
 }
]
list(any) n/a yes
vsphere_compute_cluster Name of the vSphere cluster
Example: Cluster1
string n/a yes
vsphere_datacenter Name of the datacenter in vSphere interface string n/a yes
sap_hana_database_anti_affinity_rule_enable Avoid running SAP HANA databases virtual machines on the same ESXi host bool false no
sap_hana_database_anti_affinity_rule_mandatory When this value is true, prevents any virtual machine operations that may violate this rule bool false no
sap_hana_database_anti_affinity_rule_name Name for the anti-affinity rule string "sap-hana-database-anti-affinity-rule" no
sap_hana_database_folder Name of the folder to store the SAP HANA database virtual machines string "" no
sap_hana_database_hardware_version Hardware compatibility between SAP HANA database virtual machine and ESXi host. By default, the newest version.
More information available on VMware
number 19 no
sap_hana_database_hosts_distribution Allow to set which SAP HANA database virtual machines have to run on a specific ESXi host.
When mandatory is true, prevents any virtual machine operations that may violate this rule.

Example:
[
 {
   "group_name" = "hana-primary",
   "hosts" = ["192.168.2.1", "192.168.2.2"],
   "sap_hana_databases" = ["hana1"],
   "mandatory" = true
 },
 {
   "group_name" = "hana-secondary",
   "hosts" = ["192.168.2.2", "192.168.2.3"],
   "sap_hana_databases" = ["hana2"],
   "mandatory" = false
 }
]
list(any) [] no
sap_hana_database_thick_datastore_policy This Storage Policy must be a Thick provisioning string "" no
sap_hana_database_thin_datastore_policy This Storage Policy must be a Thin provisioning string "" no
sap_hana_database_wait_for_guest_ip_timeout The amount of time, in minutes, to wait for an available guest IP address on the SAP HANA database virtual machine. number 0 no
sap_hana_database_wait_for_guest_net_timeout The amount of time, in minutes, to wait for an available guest IP address on the SAP HANA database virtual machine. number 0 no

As the variable sap_hana_databases is a list with many parameters, we present you one by one each parameter.

Name Description Type
name Name of the virtual machine. string
model The module proposes 3 models:
- S: 24vCPU and 384GB of memory
- M: 48vCPU and 768GB of memory
- L: 96vCPU and 1436GB of memory
string
cpus Number of vCPU for the virtual machine.
Mandatory if the variable model is empty.
string
cpus_per_socket Number of vCPU per socket for the virtual machine.
Mandatory even if the variable model is empty.
string
memory Number of memory (in MB) for the virtual machine.
Mandatory if the variable model is empty.
string
custom_disks The module proposes by default six disks:
 - disk0 (root) | 128 GB | Thin provisioning
 - disk1 (sap) | 32 GB | Thin provisioning
 - disk2 (hana-data) | {memory_size} GB | Thick provisioning
 - disk3 (hana-log) | {memory_size < 512 ? 1/2 memory_size : 512} GB | Thick provisioning
 - disk4 (hana-shared) | {memory_size < 1024 ? memory_size : 1024} GB | Thick provisioning
 - disk5 (hana-backup) | {hana-data + hana-log} GB | Thin provisioning

If you want to set your own configuration for disks, set the variable to true.
boolean
scsi_controller_count Number of SCSI controller.
Mandatory if the variable custom_disks is true.

VMware and SAP recommends to separate hanadata, hanalog and hanabackup on three different SCSI controllers.
number
disks List of disks wanted if the variable custom_disks has been set to true.
The default disk are no longer created if the variable custom_disks has been set to true

The structure has to be like this:
[
 { "id" : 0, "label" : "disk0", "size" : "{size in GB}", "thin_provisioned" : {true | false=thick}, "eagerly_scrub": {true (only for thick) | false}, "datastore_name" : "{datastore to store disk}", "datastore_policy" : "{datastore policy}" },
  { "id" : 1, "label" : "disk1", "size" : "{size in GB}", "thin_provisioned" : {true | false=thick}, "eagerly_scrub": {true (only for thick) | false}, "datastore_name" : "{datastore to store disk}", "datastore_policy" : "{datastore policy}" },
  { "id" : 2, "label" : "disk2", "size" : "{size in GB}", "thin_provisioned" : {true | false=thick}, "eagerly_scrub": {true (only for thick) | false}, "datastore_name" : "{datastore to store disk}", "datastore_policy" : "{datastore policy}" },
  ...
]

Each SCSI controller has 16 ID, if you want to use the second controller for your second disk, the id must be 15, for the third controller, the id must be 30, etc.

Caution, the datastore policy has to be set with the same behaviour on the thin or thick provisioning. Don't set a thin provisioning in the variable if the datastore policy set a thick provisioning.

You have also the possibility to let the datastore_policy empty (""), the Storage Policy by default for the datastore will be applied.

To know more about the Storage Policy (datastore_policy), please refer to the official documentation on VMware.
list()
networks List of network cards. list()
guest_id Operating System to be compatible between ESXi host and the virtual machine.
To know the possible value for this variable, please refer to the official list on VMware.
string
vsphere_content_library The Content Library name where the OVA is stored, if you want to create the virtual machine from a template. string
template Name of the template.
Mandatory if the variable vsphere_content_library has been set.
string
iso_datastore Datastore name where the ISO file is stored, if you want to add a CD-ROM device and start the virtual machine on it. string
iso_path Path in the datastore to locate the ISO file.
Mandatory if the variable iso_datastore is not empty.
string
vapp_options Map that you want to pass to the virtual machine.
Only available with template which has vApp Options enabled.

Example:
 {
   "guestinfo.hostname" : "vm-sap-hana",
   "guestinfo.user" : "my-user",
   "guestinfo.password" : "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
   "guestinfo.password_crypted" : "False"
 }
map

Outputs

Name Description
affinity_hosts_sap_hana_databases_rules Map of affinity hosts SAP HANA databases virtual machines rules information
anti_affinity_sap_hana_databases_rule Map of anti affinity SAP HANA databases virtual machines rule information
sap_hana_databases_ids Map of SAP HANA databases virtual machines names and its IDs

How do I contribute to this Terraform Module?

Contributions are very welcome! Check out the Contribution Guidelines for instructions.

How is this Terraform Module versioned?

This Terraform Module follows the principles of Semantic Versioning. You can find each new release, along with the changelog, in the Releases Page.

During initial development, the major version will be 0 (e.g., 0.x.y), which indicates the code does not yet have a stable API. Once we hit 1.0.0, we will make every effort to maintain a backwards compatible API and use the MAJOR, MINOR, and PATCH versions on each release to indicate any incompatibilities.

License

This code is released under the Apache 2.0 License. Please see LICENSE for more details.

About

Terraform module to create a set of SAP HANA databases virtual machines on VMware on OVHcloud.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published