Skip to content

Commit

Permalink
48 templates for azurerm (#50)
Browse files Browse the repository at this point in the history
Create new modules and templates for quickstart Exadata using AzureRM
- templates/azurerm-oci-exadata-quickstart
    - modules/azurerm-ora-exadata-infra
    - modules/azurerm-ora-exadata-vmc
    - modules/oci-database-db-home
    - modules/oci-database-db-home
  • Loading branch information
chanstev authored Oct 31, 2024
1 parent f12b692 commit aa095de
Show file tree
Hide file tree
Showing 43 changed files with 1,538 additions and 144 deletions.
2 changes: 1 addition & 1 deletion examples/az-vmc-network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
}
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.99.0"
version = ">=3.99.0"
}
}
}
Expand Down
54 changes: 54 additions & 0 deletions modules/azurerm-ora-exadata-infra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# azurerm-ora-exadata-infra

## Summary

Terraform module for Oracle Database @ Azure Exadata Infrastructure (using AzureRM Terraform Provider)

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >=4.6.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >=4.6.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [azurerm_oracle_exadata_infrastructure.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/oracle_exadata_infrastructure) | resource |
| [azurerm_oracle_exadata_infrastructure.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/oracle_exadata_infrastructure) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_compute_count"></a> [compute\_count](#input\_compute\_count) | The number of compute servers for the Exadata infrastructure. | `number` | `2` | no |
| <a name="input_customer_contacts"></a> [customer\_contacts](#input\_customer\_contacts) | The email address used by Oracle to send notifications regarding databases and infrastructure. Provide up to 10 unique maintenance contact email addresses. | `list(string)` | `[]` | no |
| <a name="input_location"></a> [location](#input\_location) | The name of Azure Region where the Exadata Infrastructure should be. e.g. useast | `string` | n/a | yes |
| <a name="input_maintenance_window"></a> [maintenance\_window](#input\_maintenance\_window) | maintenanceWindow properties | <pre>object({<br/> patching_mode = string<br/> preference = string<br/> lead_time_in_weeks = optional(number)<br/> months = optional(list(number))<br/> weeks_of_month = optional(list(number))<br/> days_of_week =optional(list(number))<br/> hours_of_day = optional(list(number))<br/> })</pre> | <pre>{<br/> "patching_mode": "Rolling",<br/> "preference": "NoPreference"<br/>}</pre> | no |
| <a name="input_name"></a> [name](#input\_name) | The name of the Exadata Infrastructure at Azure | `string` | `"odaaz-infra"` | no |
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | The name of Resource Group in Azure | `string` | `"rg-oradb"` | no |
| <a name="input_shape"></a> [shape](#input\_shape) | The shape of the Exadata infrastructure resource. e.g. Exadata.X9M | `string` | `"Exadata.X9M"` | no |
| <a name="input_storage_count"></a> [storage\_count](#input\_storage\_count) | The number of storage servers for the Exadata infrastructure. | `number` | `3` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Resource tags for the Cloud Exadata Infrastructure | `map(string)` | `null` | no |
| <a name="input_zone"></a> [zone](#input\_zone) | The availablty zone of the Exadata Infrastructure in Azure | `string` | n/a | yes |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_oci_compartment_ocid"></a> [oci\_compartment\_ocid](#output\_oci\_compartment\_ocid) | Compartment OCID of the Exadata Infrastructure in OCI |
| <a name="output_oci_region"></a> [oci\_region](#output\_oci\_region) | Region of the Exadata Infrastructure in OCI |
| <a name="output_resource"></a> [resource](#output\_resource) | Resource Object of Exadata Infrastructure in Azure |
| <a name="output_resource_id"></a> [resource\_id](#output\_resource\_id) | Resource ID of Exadata Infrastructure in Azure |
<!-- END_TF_DOCS -->
44 changes: 44 additions & 0 deletions modules/azurerm-ora-exadata-infra/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# https://github.com/hashicorp/terraform-provider-azurerm/releases
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=4.6.0"
}
}
}

resource "azurerm_oracle_exadata_infrastructure" "this" {
# Required
resource_group_name = var.resource_group_name
location = var.location
zones = [var.zone]

name = var.name
display_name = var.name

shape = var.shape
compute_count = var.compute_count
storage_count = var.storage_count

# Optional
customer_contacts = var.customer_contacts
tags = var.tags

maintenance_window {
patching_mode = var.maintenance_window.patching_mode
preference = var.maintenance_window.preference
lead_time_in_weeks = coalesce(var.maintenance_window.lead_time_in_weeks,1)
months = coalesce(var.maintenance_window.months,[])
weeks_of_month = coalesce(var.maintenance_window.weeks_of_month,[])
days_of_week = coalesce(var.maintenance_window.days_of_week,[])
hours_of_day = coalesce(var.maintenance_window.hours_of_day,[])
}

}

data "azurerm_oracle_exadata_infrastructure" "this" {
name = var.name
resource_group_name = var.resource_group_name
depends_on = [azurerm_oracle_exadata_infrastructure.this]
}
19 changes: 19 additions & 0 deletions modules/azurerm-ora-exadata-infra/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
output "resource_id" {
description = "Resource ID of Exadata Infrastructure in Azure"
value = azurerm_oracle_exadata_infrastructure.this.id
}

output "resource" {
description = "Resource Object of Exadata Infrastructure in Azure"
value = azurerm_oracle_exadata_infrastructure.this
}

output "oci_region" {
description = "Region of the Exadata Infrastructure in OCI"
value = regex("(?:region=)([^?&/]+)",data.azurerm_oracle_exadata_infrastructure.this.oci_url)[0]
}

output "oci_compartment_ocid" {
description = "Compartment OCID of the Exadata Infrastructure in OCI"
value = regex("(?:compartmentId=)([^?&/]+)",data.azurerm_oracle_exadata_infrastructure.this.oci_url)[0]
}
70 changes: 70 additions & 0 deletions modules/azurerm-ora-exadata-infra/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Mandatory
variable "location" {
description = "The name of Azure Region where the Exadata Infrastructure should be. e.g. useast"
type = string
}

variable "name" {
description = "The name of the Exadata Infrastructure at Azure"
type = string
default = "odaaz-infra"
}

variable "resource_group_name" {
description = "The name of Resource Group in Azure"
type = string
default = "rg-oradb"
}

variable "zone" {
description = "The availablty zone of the Exadata Infrastructure in Azure"
type = string
}

variable "compute_count" {
description = "The number of compute servers for the Exadata infrastructure."
type = number
default = 2
}

variable "storage_count" {
description = "The number of storage servers for the Exadata infrastructure."
type = number
default = 3
}

variable "shape" {
description = "The shape of the Exadata infrastructure resource. e.g. Exadata.X9M"
type = string
default = "Exadata.X9M"
}

# Optional
variable "customer_contacts" {
description = "The email address used by Oracle to send notifications regarding databases and infrastructure. Provide up to 10 unique maintenance contact email addresses."
type = list(string)
default = []
}

variable "maintenance_window" {
description = "maintenanceWindow properties"
type = object({
patching_mode = string
preference = string
lead_time_in_weeks = optional(number)
months = optional(list(number))
weeks_of_month = optional(list(number))
days_of_week =optional(list(number))
hours_of_day = optional(list(number))
})
default = {
patching_mode = "Rolling"
preference = "NoPreference"
}
}

variable "tags" {
description = "Resource tags for the Cloud Exadata Infrastructure"
type = map(string)
default = null
}
77 changes: 77 additions & 0 deletions modules/azurerm-ora-exadata-vmc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# azurerm-ora-exadata-vmc

## Summary

Terraform module for Oracle Database @ Azure Exadata VM Cluster (using AzureRM Terraform Provider)

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | >=4.6.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | >=4.6.0 |
| <a name="provider_time"></a> [time](#provider\_time) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [azurerm_oracle_cloud_vm_cluster.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/oracle_cloud_vm_cluster) | resource |
| [time_sleep.wait_10s](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [azurerm_oracle_cloud_vm_cluster.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/oracle_cloud_vm_cluster) | data source |
| [azurerm_oracle_db_servers.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/oracle_db_servers) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_backup_subnet_cidr"></a> [backup\_subnet\_cidr](#input\_backup\_subnet\_cidr) | The backup subnet CIDR of the Virtual Network associated with the Cloud VM Cluster. | `string` | `null` | no |
| <a name="input_cloud_exadata_infrastructure_id"></a> [cloud\_exadata\_infrastructure\_id](#input\_cloud\_exadata\_infrastructure\_id) | The OCID of the Cloud Exadata infrastructure. | `string` | n/a | yes |
| <a name="input_cloud_exadata_infrastructure_name"></a> [cloud\_exadata\_infrastructure\_name](#input\_cloud\_exadata\_infrastructure\_name) | The name of the Cloud Exadata infrastructure. | `string` | n/a | yes |
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The cluster name for cloud VM cluster. The cluster name must begin with an alphabetic character, and may contain hyphens (-). Underscores (\_) are not permitted. The cluster name can be no longer than 11 characters and is not case sensitive. | `string` | `null` | no |
| <a name="input_cpu_core_count"></a> [cpu\_core\_count](#input\_cpu\_core\_count) | The number of CPU cores enabled on the Cloud VM Cluster. | `string` | n/a | yes |
| <a name="input_data_storage_percentage"></a> [data\_storage\_percentage](#input\_data\_storage\_percentage) | The percentage assigned to DATA storage (user data and database files). The remaining percentage is assigned to RECO storage (database redo logs, archive logs, and recovery manager backups). Accepted values are 35, 40, 60 and 80. | `number` | `null` | no |
| <a name="input_data_storage_size_in_tbs"></a> [data\_storage\_size\_in\_tbs](#input\_data\_storage\_size\_in\_tbs) | The data disk group size to be allocated in TBs. | `number` | `null` | no |
| <a name="input_dbnode_storage_size_in_gbs"></a> [dbnode\_storage\_size\_in\_gbs](#input\_dbnode\_storage\_size\_in\_gbs) | The local node storage to be allocated in GBs. | `number` | `null` | no |
| <a name="input_domain"></a> [domain](#input\_domain) | The name of the existing OCI Private DNS Zone to be associated with the Cloud VM Cluster. This allow you to specify your own private domain name instead of the default OCI DNS zone (oraclevcn.com) | `string` | `""` | no |
| <a name="input_gi_version"></a> [gi\_version](#input\_gi\_version) | A valid Oracle Grid Infrastructure (GI) software version. | `string` | n/a | yes |
| <a name="input_hostname"></a> [hostname](#input\_hostname) | The prefix forms the first portion of the Exadata VM Cluster host name. Recommended maximum: 12 characters. | `string` | `null` | no |
| <a name="input_is_diagnostic_events_enabled"></a> [is\_diagnostic\_events\_enabled](#input\_is\_diagnostic\_events\_enabled) | Indicates whether diagnostic collection is enabled for the Cloud VM Cluster. Enabling diagnostic collection allows you to receive Events service notifications for guest VM issues. Diagnostic collection also allows Oracle to provide enhanced service and proactive support for your Exadata system. You can enable diagnostic collection during VM Cluster/Cloud VM Cluster provisioning. | `bool` | `false` | no |
| <a name="input_is_health_monitoring_enabled"></a> [is\_health\_monitoring\_enabled](#input\_is\_health\_monitoring\_enabled) | Indicates whether health monitoring is enabled for the Cloud VM Cluster. Enabling health monitoring allows Oracle to collect diagnostic data and share it with its operations and support personnel. You may also receive notifications for some events. Collecting health diagnostics enables Oracle to provide proactive support and enhanced service for your system. Optionally enable health monitoring while provisioning a system. | `bool` | `false` | no |
| <a name="input_is_incident_logs_enabled"></a> [is\_incident\_logs\_enabled](#input\_is\_incident\_logs\_enabled) | Indicates whether incident logs and trace collection are enabled for the Cloud VM Cluster. Enabling incident logs collection allows Oracle to receive Events service notifications for guest VM issues, collect incident logs and traces, and use them to diagnose issues and resolve them. Optionally enable incident logs collection while provisioning a system. | `bool` | `false` | no |
| <a name="input_is_local_backup_enabled"></a> [is\_local\_backup\_enabled](#input\_is\_local\_backup\_enabled) | If true, database backup on local Exadata storage is configured for the Cloud VM Cluster. If false, database backup on local Exadata storage is not available in the Cloud VM Cluster. | `bool` | `null` | no |
| <a name="input_is_sparse_diskgroup_enabled"></a> [is\_sparse\_diskgroup\_enabled](#input\_is\_sparse\_diskgroup\_enabled) | If true, the sparse disk group is configured for the Cloud VM Cluster. If false, the sparse disk group is not created. | `bool` | `null` | no |
| <a name="input_license_model"></a> [license\_model](#input\_license\_model) | The Oracle license model that applies to the Cloud VM Cluster, either BringYourOwnLicense or LicenseIncluded. | `string` | `"LicenseIncluded"` | no |
| <a name="input_location"></a> [location](#input\_location) | The Azure Region where the Cloud VM Cluster should exist. | `string` | n/a | yes |
| <a name="input_memory_size_in_gbs"></a> [memory\_size\_in\_gbs](#input\_memory\_size\_in\_gbs) | The memory to be allocated in GBs. | `number` | `null` | no |
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | The name of the Resource Group where the Cloud VM Cluster should exist | `string` | n/a | yes |
| <a name="input_ssh_public_keys"></a> [ssh\_public\_keys](#input\_ssh\_public\_keys) | The public key portion of one or more key pairs used for SSH access to the Cloud VM Cluster. | `list(string)` | n/a | yes |
| <a name="input_subnet_id"></a> [subnet\_id](#input\_subnet\_id) | The ID of the subnet associated with the Cloud VM Cluster. | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags which should be assigned to the Cloud VM Cluster. | `map(string)` | `null` | no |
| <a name="input_time_zone"></a> [time\_zone](#input\_time\_zone) | The time zone of the Cloud VM Cluster. For details, see Exadata Infrastructure Time Zones. | `string` | `null` | no |
| <a name="input_vnet_id"></a> [vnet\_id](#input\_vnet\_id) | The ID of the Virtual Network associated with the Cloud VM Cluster. | `string` | n/a | yes |
| <a name="input_zone_id"></a> [zone\_id](#input\_zone\_id) | The OCID of the existing OCI Private DNS Zone to be associated with the Cloud VM Cluster. This allow you to specify your own private domain name instead of the default OCI DNS zone (oraclevcn.com) | `string` | `""` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_oci_compartment_ocid"></a> [oci\_compartment\_ocid](#output\_oci\_compartment\_ocid) | Compartment OCID of the VM Cluster in OCI |
| <a name="output_oci_nsg_ocid"></a> [oci\_nsg\_ocid](#output\_oci\_nsg\_ocid) | OCID of the Network Security Group (NSG) in OCI |
| <a name="output_oci_region"></a> [oci\_region](#output\_oci\_region) | Region of the VM Cluster in OCI |
| <a name="output_oci_vcn_ocid"></a> [oci\_vcn\_ocid](#output\_oci\_vcn\_ocid) | OCID of the Virtual Cloud Network (VCN)in OCI |
| <a name="output_resource"></a> [resource](#output\_resource) | Resource Object of VM Cluster in Azure |
| <a name="output_resource_id"></a> [resource\_id](#output\_resource\_id) | Resource ID of the VM Cluster in Azure |
| <a name="output_vm_cluster_hostname_actual"></a> [vm\_cluster\_hostname\_actual](#output\_vm\_cluster\_hostname\_actual) | The actual hostname of the VM Cluster after provision |
| <a name="output_vm_cluster_ocid"></a> [vm\_cluster\_ocid](#output\_vm\_cluster\_ocid) | OCID of the VM Cluster in OCI |
<!-- END_TF_DOCS -->
82 changes: 82 additions & 0 deletions modules/azurerm-ora-exadata-vmc/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# https://github.com/hashicorp/terraform-provider-azurerm/releases
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=4.6.0"
}
}
}

data "azurerm_oracle_db_servers" "this" {
resource_group_name = var.resource_group_name
cloud_exadata_infrastructure_name = var.cloud_exadata_infrastructure_name
}

resource "azurerm_oracle_cloud_vm_cluster" "this" {

# VM Cluster details
resource_group_name = var.resource_group_name
location = var.location
cloud_exadata_infrastructure_id = var.cloud_exadata_infrastructure_id
cluster_name = var.cluster_name
name = var.cluster_name
display_name = var.cluster_name
hostname = var.hostname
# hostname_actual = var.hostname_actual != null ? var.hostname_actual : null
time_zone = var.time_zone
license_model = var.license_model
gi_version = var.gi_version

ssh_public_keys = var.ssh_public_keys
db_servers = [for obj in data.azurerm_oracle_db_servers.this.db_servers : obj.ocid]

# Networking
virtual_network_id = var.vnet_id
subnet_id = var.subnet_id
backup_subnet_cidr = var.backup_subnet_cidr
domain = var.domain #!= "" ? var.domain : null
zone_id = var.zone_id #!= "" ? var.zone_id : null

# VM Cluster allocation
cpu_core_count = var.cpu_core_count
memory_size_in_gbs = var.memory_size_in_gbs
db_node_storage_size_in_gbs = var.dbnode_storage_size_in_gbs

# Exadata storage
data_storage_size_in_tbs = var.data_storage_size_in_tbs
data_storage_percentage= var.data_storage_percentage
local_backup_enabled = var.is_local_backup_enabled
sparse_diskgroup_enabled = var.is_sparse_diskgroup_enabled

# Diagnostics Collection
data_collection_options {
diagnostics_events_enabled = var.is_diagnostic_events_enabled
health_monitoring_enabled = var.is_health_monitoring_enabled
incident_logs_enabled = var.is_incident_logs_enabled
}

tags = var.tags

lifecycle {
ignore_changes = [
id,
cluster_name,
gi_version,
# hostname_actual,
backup_subnet_cidr
]
}
}

# Lookup OCID of VM Cluster for output
resource "time_sleep" "wait_10s" {
create_duration = "10s"
depends_on = [azurerm_oracle_cloud_vm_cluster.this]
}

data "azurerm_oracle_cloud_vm_cluster" "this" {
depends_on = [ time_sleep.wait_10s ]
name = azurerm_oracle_cloud_vm_cluster.this.name
resource_group_name = var.resource_group_name
}
Loading

0 comments on commit aa095de

Please sign in to comment.