terraform-provider-vsphere
terraform-provider-vsphere copied to clipboard
fix: allow `datastore_cluster_id` for content library clones
Description
- Allows specifying a
datastore_cluster_id
forvsphere_virtual_machine
when cloning fromvsphere_content_library_item
Fixes #2055
References
https://kb.vmware.com/s/article/91103
Hi @bFekete could you please provide a HCL which deploys a VM from content library on datastore cluster and has output some of the newly created VM properties , like the id for example? This must be executed with version of the provider containing your fix. The output of terraform apply
will also be required.
Best Regards, Vasil
Hi @bFekete could you please provide a HCL which deploys a VM from content library on datastore cluster and has output some of the newly created VM properties , like the id for example? This must be executed with version of the provider containing your fix. The output of
terraform apply
will also be required.Best Regards, Vasil
Can't provide all that info due to policies. Here's a rough outline
data "vsphere_datacenter" "this" {
name = "test-dc"
}
data "vsphere_datastore_cluster" "this" {
name = "test-dsc"
datacenter_id = data.vsphere_datacenter.this.id
}
data "vsphere_content_library" "library" {
name = "test-cl"
}
data "vsphere_content_library_item" "ovf" {
name = "test-ovf-template"
type = "ovf"
library = data.vsphere_content_library.library.id
}
resource "vsphere_virtual_machine" "this" {
....
datastore_cluster_id = data.vsphere_datastore_cluster.this,id
clone {
template_uuid = data.vsphere_content_library_item.ovf.id
customize {
...
}
}
...
}
Here's an example from a project I maintain. Just change to datastore cluster datasource and use it in r/virtual_machine
.
Hi. Is there any work required to merge this? I am happy to help move this forward.
Yes, it needs review, testing, and regression testing before merged - when time permits us to prioritize.
There is contradicting content product documentation and the KB.
Documentation: https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-vm-administration/GUID-6EA309BC-9113-449C-B668-ACBB363485C3.html infers supported.
KB: https://kb.vmware.com/s/article/91103 states that it is not supported.
I'll track this item down with engineering so that this can be reviewed and any contradictory information resolved.
Hi @tenthirtyam. What's the issue preventing this fix from being merged?
Hi @tenthirtyam. What's the issue preventing this fix from being merged?
Please refer to https://github.com/hashicorp/terraform-provider-vsphere/pull/2061#issuecomment-1981570804.
I've tested this change and unfortunately it is insufficient to achieve the desired results.
You would see such errors as follows:
➜ clone-ovf-esxi-simple git:(main) ✗ terraform apply ╷ │ Error: Unsupported argument │ │ on main.tf line 60, in data "vsphere_ovf_vm_template" "ovf": │ 60: datastore_cluster_id = data.vsphere_datastore_cluster.datastore_cluster.id │ │ An argument named "datastore_cluster_id" is not expected here.
or
vsphere_virtual_machine.nested_esxi: Creating... ╷ │ Error: while extracting OVF parameters: data store ID is required for ovf deployment │ │ with vsphere_virtual_machine.nested_esxi, │ on main.tf line 73, in resource "vsphere_virtual_machine" "nested_esxi": │ 73: resource "vsphere_virtual_machine" "nested_esxi" {
This will require supported changes to the OVF helper and
r/virtual_machine
.Ryan
cc @iBrandyJackson
The PR is specific for provisioning a VM by cloning an OVF from a content library. It was tested against content library clones. In your test code, you are using the data source ovf vm template which doesn’t even support ovfs from a content library. Also it looks like its using an OVF deploy instead of a clone
Thanks for clarifying the use case. I'll review again tomorrow.
This functionality has been released in v2.8.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!
I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.