Skip to content

Commit

Permalink
add source volumen to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Oehrli committed May 10, 2021
1 parent 4b5feb3 commit dc2d4b1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Variables for the configuration of the terraform module, defined in [variables](
| `host_shape` | The shape of compute instance. | | VM.Standard2.2 |
| `host_boot_volume_size` | Size of the boot volume. | | 150 |
| `host_volume_enabled` | Whether to create an additional volume or not. | true/false | false |
| `host_volume_source` | OCID of the source volume to clone. | OCID | n/a |
| `host_volume_attachment_type` | The type of volume | iscsi/paravirtualized | paravirtualized |
| `host_volume_size` | Size of the volume. | | 256 |
| `host_state` | Whether host should be either RUNNING or STOPPED state. | RUNNING / STOPPED | RUNNING |
Expand Down
7 changes: 7 additions & 0 deletions examples/linux/additional_linux_host.tf
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ variable "host_volume_enabled" {
type = bool
}

variable "host_volume_source" {
description = "Source block volume to clone from."
default = ""
type = string
}

variable "host_volume_attachment_type" {
description = "The type of volume."
default = "paravirtualized"
Expand Down Expand Up @@ -267,6 +273,7 @@ module "tvdlab-linux-host" {
host_os_version = var.linux_host_os_version
host_boot_volume_size = var.linux_host_boot_volume_size
host_volume_enabled = var.linux_volume_enabled
host_volume_source = var.linux_volume_source
host_volume_attachment_type = var.linux_volume_attachment_type
host_volume_size = var.linux_volume_size
}
Expand Down
1 change: 1 addition & 0 deletions examples/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ host_os_version = "7.8"
host_shape = "VM.Standard2.2"
host_boot_volume_size = 150
host_volume_enabled = false
host_volume_source = ""
host_volume_attachment_type = "paravirtualized"
host_volume_size = 256
host_state = "RUNNING"
Expand Down
6 changes: 6 additions & 0 deletions examples/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ variable "host_volume_enabled" {
type = bool
}

variable "host_volume_source" {
description = "Source block volume to clone from."
default = ""
type = string
}

variable "host_volume_attachment_type" {
description = "The type of volume."
default = "paravirtualized"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ variable "host_volume_enabled" {
type = bool
}

variable "host_volume_source" {
description = "Source block volume to clone from."
default = ""
type = string
}

variable "host_volume_attachment_type" {
description = "The type of volume."
default = "paravirtualized"
Expand Down
8 changes: 8 additions & 0 deletions volumes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ resource "oci_core_volume" "CreateVolume" {
display_name = var.label_prefix == "none" ? format("${local.resource_shortname}-${var.host_name}%02d-volume", count.index) : format("${var.label_prefix}-${local.resource_shortname}-${var.host_name}%02d-volume", count.index)
size_in_gbs = var.host_volume_size
freeform_tags = var.tags

dynamic "source_details" {
for_each = var.host_volume_source == "" ? [] : [1]
content {
id = var.host_volume_source
type = "volume"
}
}
}

resource "oci_core_volume_attachment" "CreateVolumeAttachment" {
Expand Down

0 comments on commit dc2d4b1

Please sign in to comment.