terraform-provider-vsphere icon indicating copy to clipboard operation
terraform-provider-vsphere copied to clipboard

fix: allow `datastore_cluster_id` for content library clones

Open bFekete opened this issue 1 year ago • 5 comments

Description

  • Allows specifying a datastore_cluster_id for vsphere_virtual_machine when cloning from vsphere_content_library_item

Fixes #2055

References

https://kb.vmware.com/s/article/91103

bFekete avatar Nov 13 '23 12:11 bFekete

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

vasilsatanasov avatar Nov 13 '23 15:11 vasilsatanasov

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 {
...
         }
    }
...
}

bFekete avatar Nov 13 '23 16:11 bFekete

Here's an example from a project I maintain. Just change to datastore cluster datasource and use it in r/virtual_machine.

tenthirtyam avatar Nov 13 '23 17:11 tenthirtyam

Hi. Is there any work required to merge this? I am happy to help move this forward.

tlitovsk avatar Jan 31 '24 21:01 tlitovsk

Yes, it needs review, testing, and regression testing before merged - when time permits us to prioritize.

tenthirtyam avatar Jan 31 '24 21:01 tenthirtyam

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.

tenthirtyam avatar Mar 06 '24 18:03 tenthirtyam

Hi @tenthirtyam. What's the issue preventing this fix from being merged?

FlorianLaunay avatar Apr 29 '24 17:04 FlorianLaunay

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.

tenthirtyam avatar Apr 29 '24 17:04 tenthirtyam

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

bFekete avatar Apr 30 '24 21:04 bFekete

Thanks for clarifying the use case. I'll review again tomorrow.

tenthirtyam avatar Apr 30 '24 22:04 tenthirtyam

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!

github-actions[bot] avatar May 08 '24 21:05 github-actions[bot]

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.

github-actions[bot] avatar Jun 08 '24 02:06 github-actions[bot]