Skip to content

Commit

Permalink
Merge pull request #157 from damnsam/network-and-disk-updates
Browse files Browse the repository at this point in the history
Network and disk updates
- Add three new properties to data_disk (disk_sharing, attach, and path)
These three new properties (along with the existing datastore_id, disk_mode and unit_number) are required to enable the ability to add shared disks created by a separate "vsphere_virtual_disk" resource. For example, a main.tf could contain:
  • Loading branch information
Arman-Keyoumarsi committed Nov 5, 2023
2 parents 00b55db + 69cc089 commit e47cf7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ data "vsphere_resource_pool" "pool" {

data "vsphere_network" "network" {
count = length(var.network)
name = keys(var.network)[count.index]
name = var.network_delimiter != null ? split(var.network_delimiter,keys(var.network)[count.index])[1] : keys(var.network)[count.index]
datacenter_id = data.vsphere_datacenter.dc.id
}

Expand Down Expand Up @@ -207,6 +207,9 @@ resource "vsphere_virtual_machine" "vm" {
io_share_level = lookup(terraform_disks.value, "io_share_level", "normal")
io_share_count = lookup(terraform_disks.value, "io_share_level", null) == "custom" ? lookup(terraform_disks.value, "io_share_count") : null
disk_mode = lookup(terraform_disks.value, "disk_mode", null)
disk_sharing = lookup(terraform_disks.value, "disk_sharing", null)
attach = lookup(terraform_disks.value, "attach", null)
path = lookup(terraform_disks.value, "path", null)
}
}
clone {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ variable "network" {
default = {}
}

variable "network_delimiter" {
description = "If network name needs a delimiter for sequencing, define an UNUSED character here, otherwise leave as null"
type = string
default = null
}

variable "network_type" {
description = "Define network type for each network interface."
type = list(any)
Expand Down

0 comments on commit e47cf7e

Please sign in to comment.