Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

oracle-devrel/terraform-oci-cloudbricks-linux-iscsi-disks

Repository files navigation

OCI Cloud Bricks: iSCSI Disks (Linux)

License: UPL Quality gate

Introduction

The following cloud brick enables you to create batches of iscsi disks associated to a specific IaaS Linux Compute

Reference Architecture

The following is the reference architecture associated to the brick

Reference Architecture

Prerequisites

  • This module needs to be used associated with a Linux Compute IaC Creation, as it depends on variable compute_availability_domain_list which needs to be pre-defined.
  • Linux Compute Distributions currently supported under this module are:
    • CentOS 6.x
    • CentOS 7.x
    • CentOs 8.x
    • Oracle Autonomous Linux 7.x
    • Oracle Linux 6.x
    • Oracle Linux 7.x
    • Oracle Linux 8.x
    • Custom images based on RHEL
    • Ubuntu

Sample tfvar file

########## SAMPLE TFVAR FILE ##########
########## PROVIDER SPECIFIC VARIABLES ##########
region           = "foo-region-1"
tenancy_ocid     = "ocid1.tenancy.oc1..abcdefg"
user_ocid        = "ocid1.user.oc1..aaaaaaabcdefg"
fingerprint      = "fo:oo:ba:ar:ba:ar"
private_key_path = "/absolute/path/to/api/key/your_api_key.pem"
########## PROVIDER SPECIFIC VARIABLES ##########

########## ARTIFACT SPECIFIC VARIABLES ##########
amount_of_disks                      = "2"
disk_size_in_gb                      = "50"
iscsi_disk_instance_compartment_name = "MY_ARTIFACT_COMPARTMENT"
volume_display_name                  = "diskbasename"
backup_policy_level                  = "gold"
is_opc                               = false
########## ARTIFACT SPECIFIC VARIABLES ##########
########## SAMPLE TFVAR FILE ##########

Variable specific considerations

  • Variable amount_of_disks represents the number of disks being created. This has to be a minimum of 1
  • Minimum disk size is 50GB
  • Variable iscsi_disk_instance_compartment_name refers to the compartment where this artifact will be associated/created into
  • Variable volume_display_name represents the base name of the disk. This will be later concatenated with the amount of disks given by variable amount_of_disks and the name of the associated instance, being something like computedisplayname_diskbasename_0_, computedisplayname_diskbasename_1, computedisplayname_diskbasename_N where N will match the variable
  • Variable backup_policy_level associates the backup policy level given to the disks. By default bronze, silver and gold are available, however this also supports custom policies. This variable will take the name of such policy and apply it to disk
  • If Disk is provisioned decoupled from Compute, in a different run, the following extra entries are required on tfvars file:
compute_availability_domain_list = ["aBCD:foo-REGION-1-AD-X" ]
compute_display_name             = "DISPLAY_NAME_OF_ASSOCIATED_INSTANCE"
linux_compute_id                 = "OCID_OF_ASSOCIATED_INSTANCE"
linux_compute_private_ip         = "PRIVATE_IP_OF_INSTANCE"
ssh_private_key                  = "PRIVATE_SSH_KEY_OF_INSTANCE"

Special Considerations

  • The above described variables have the following purpose
    • compute_availability_domain_list: This is the exact AD where the Linux Instance got created. A single entry is required here
    • compute_display_name: The display name given to the Linux Instance
    • linux_compute_id: The OCID associated to the Linux Instance
    • ssh_private_key: The SSH Private Key associated to the created Linux Instance

Sample provider

The following is the base provider definition to be used with this module

terraform {
  required_version = ">= 0.13.5"
}
provider "oci" {
  region       = var.region
  tenancy_ocid = var.tenancy_ocid
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  disable_auto_retries = "true"
}

provider "oci" {
  alias        = "home"
  region       = data.oci_identity_region_subscriptions.home_region_subscriptions.region_subscriptions[0].region_name
  tenancy_ocid = var.tenancy_ocid  
  user_ocid        = var.user_ocid
  fingerprint      = var.fingerprint
  private_key_path = var.private_key_path
  disable_auto_retries = "true"
}

Variable documentation

Requirements

Name Version
terraform >= 0.13.5

Providers

Name Version
null 3.1.0
oci 4.36.0

Modules

No modules.

Resources

Name Type
null_resource.format_disk_exec resource
null_resource.mount_disk_exec resource
null_resource.partition_disk resource
null_resource.provisioning_disk resource
null_resource.pvcreate_exec resource
null_resource.vgcreate_exec resource
oci_core_volume.ISCSIDisk resource
oci_core_volume_attachment.ISCSIDiskAttachment resource
oci_core_volume_backup_policy_assignment.backup_policy_assignment_ISCSI_Disk resource
oci_core_volume_backup_policies.BACKUPPOLICYISCSI data source
oci_identity_compartments.COMPARTMENTS data source

Inputs

Name Description Type Default Required
amount_of_disks Amount of equally sized disks any n/a yes
attach_disks Atach disk to a Linux instance bool true no
attachment_type Atacchment type can be iscsi or paravirtualized string "iscsi" no
backup_policy_level Backup policy level for ISCSI disks any n/a yes
compute_availability_domain_list Availability Domain where the block storage will be created at any n/a yes
compute_display_name Name of the compute where the disk will be attached to any n/a yes
disk_size_in_gb Size in GB for Product Disk any n/a yes
fingerprint API Key Fingerprint for user_ocid derived from public API Key imported in OCI User config any n/a yes
is_opc Describes if user to use is opc or not. Setting this to false, will default to ubuntu user bool true no
iscsi_disk_instance_compartment_name Defines the compartment name where the infrastructure will be created any n/a yes
linux_compute_id OCI Id for instance to attach the disk any null no
linux_compute_private_ip Compute private IP to logon into machine any n/a yes
private_key_path Private Key Absolute path location where terraform is executed any n/a yes
region Target region where artifacts are going to be created any n/a yes
ssh_private_is_path Determines if key is supposed to be on file or in text bool true no
ssh_private_key Determines what is the private key to connect to machine any n/a yes
tenancy_ocid OCID of tenancy any n/a yes
user_ocid User OCID in tenancy. any n/a yes
volume_display_name Disk display name. any n/a yes
vpus_per_gb n/a number 10 no

Outputs

Name Description
core_volumens n/a
core_volumens_attachment n/a
volumen_ids n/a

Contributing

This project is open source. Please submit your contributions by forking this repository and submitting a pull request! Oracle appreciates any contributions that are made by the open source community.

License

Copyright (c) 2021 Oracle and/or its affiliates.

Licensed under the Universal Permissive License (UPL), Version 1.0.

See LICENSE for more details.