Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for additional disks when creating a VM from a vsphere_ovf_vm_template #2000

Closed
4 tasks done
joaofeteira opened this issue Aug 23, 2023 · 4 comments
Closed
4 tasks done
Labels
enhancement Type: Enhancement

Comments

@joaofeteira
Copy link

Community Guidelines

  • I have read and agree to the HashiCorp Community Guidelines .
  • Vote on this issue by adding a 👍 reaction to the original issue initial description to help the maintainers prioritize.
  • Do not leave "+1" or other comments that do not add relevant information or questions.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Hi,

Would it be possible to add additional disks when creating a VM from an OVF template?
Right now it seems it isn't since when explicitly adding the disks parameter inside the vsphere_virtual_machine resource it just replaces the existing ova included disk. Also the OVA template data doesn't have the disks parameter so we cannot access it.
BR

Use Case(s)

Additional disks on existing ova image

Potential Terraform Provider Configuration

No response

References

No response

@joaofeteira joaofeteira added the enhancement Type: Enhancement label Aug 23, 2023
@github-actions
Copy link

Hello, joaofeteira! 🖐

Thank you for submitting an issue for this provider. The issue will now enter into the issue lifecycle.

If you want to contribute to this project, please review the contributing guidelines and information on submitting pull requests.

@tenthirtyam tenthirtyam added vsphere/v8 vSphere 8.0 and removed vsphere/v8 vSphere 8.0 labels Sep 5, 2023
@adeturner
Copy link

@joaofeteira, doesnt this do it? My vm has sda and sdb devices created correctly

data "vsphere_content_library_item" "MY_OVF" {
  name       = var.my_image_name
  type       = "ovf"
  library_id = data.vsphere_content_library.CL_PACKER_IMAGES.id
}

resource "vsphere_virtual_disk" "mydisk" {
  size               = 20
  type               = "thin"
  vmdk_path          = "/${local.hostname}/mydisk.vmdk"
  create_directories = true
  datacenter         = data.vsphere_datacenter.datacenter.name
  datastore          = data.vsphere_datastore.datastore.name
}

resource "vsphere_virtual_machine" "my_vm" {
...
  disk {
    # https://registry.terraform.io/providers/hashicorp/vsphere/latest/docs/resources/virtual_machine#disk-options
    label       = "disk0"
    size        = 40
    unit_number = 0 # must be unique (default 0)
  }

  disk {
    label        = "disk1"
    attach       = true
    datastore_id = data.vsphere_datastore.datastore.id
    path         = vsphere_virtual_disk.mydisk.vmdk_path
    unit_number  = 1 # must be unique
  }

  clone {
    template_uuid = data.vsphere_content_library_item.MY_OVF.id
    customize { ... }
  }
}
# fdisk -l /dev/sda
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 721EE3FF-179F-4B3F-8391-A13AA3C60164

Device       Start      End  Sectors Size Type
/dev/sda1     2048  2099199  2097152   1G EFI System
/dev/sda2  2099200  4196351  2097152   1G Linux filesystem
/dev/sda3  4196352 83884031 79687680  38G Linux filesystem

# fdisk -l /dev/sdb
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

@joaofeteira
Copy link
Author

Hi,

I think I have tested it like you have described and it didn't work. In my use case I am not using content library but instead the vsphere_ovf_vm_template data and the vsphere_virtual_machine resource with the ovf_deploy option. That might be the difference.
I will close this for now and test it again when I have some more time.
Thanks for the help.

Copy link

github-actions bot commented Nov 2, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Type: Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants