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

fix: allow datastore_cluster for content library clones #2061

Merged

Conversation

bFekete
Copy link
Contributor

@bFekete bFekete commented Nov 13, 2023

Description

Allows specifying a datastore_cluster_id for vsphere_virtual_machine when cloning from vsphere_content_library_item.

References

Closes #2055

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

@bFekete bFekete requested a review from a team as a code owner November 13, 2023 12:17
@github-actions github-actions bot added provider Type: Provider size/xs Relative Sizing: Extra-Small labels Nov 13, 2023
@vasilsatanasov
Copy link
Contributor

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

@tenthirtyam tenthirtyam added this to the v2.6.0 milestone Nov 13, 2023
@tenthirtyam tenthirtyam changed the title allow datastore cluster id for library clones fix: allow datastore_cluster_id for content library clones Nov 13, 2023
@bFekete
Copy link
Contributor Author

bFekete commented Nov 13, 2023

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

@tenthirtyam
Copy link
Collaborator

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

@tenthirtyam tenthirtyam changed the title fix: allow datastore_cluster_id for content library clones fix: allow datastore_cluster_id for content library clones Nov 14, 2023
@tenthirtyam tenthirtyam modified the milestones: v2.6.0, v2.7.0 Nov 17, 2023
@tenthirtyam tenthirtyam modified the milestones: v2.7.0, On Deck Jan 23, 2024
@tlitovsk
Copy link

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

@tenthirtyam
Copy link
Collaborator

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

@tenthirtyam
Copy link
Collaborator

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 tenthirtyam force-pushed the fix/content-library-deploy-ds-cluster branch from ca1ba09 to 65ab6e9 Compare March 13, 2024 02:01
@tenthirtyam tenthirtyam modified the milestones: v2.8.0, On Deck Apr 29, 2024
@FlorianLaunay
Copy link

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

@tenthirtyam
Copy link
Collaborator

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

Please refer to #2061 (comment).

@tenthirtyam tenthirtyam force-pushed the fix/content-library-deploy-ds-cluster branch from 65ab6e9 to 6e0af62 Compare April 29, 2024 17:05
@tenthirtyam tenthirtyam force-pushed the fix/content-library-deploy-ds-cluster branch from 6e0af62 to 552a385 Compare April 30, 2024 20:03
@github-actions github-actions bot added the needs-review Status: Pull Request Needs Review label Apr 30, 2024
@tenthirtyam tenthirtyam marked this pull request as draft April 30, 2024 20:08
@tenthirtyam tenthirtyam added do-not-merge Status: Draft, Do Not Merge and removed needs-review Status: Pull Request Needs Review labels Apr 30, 2024
@bFekete
Copy link
Contributor Author

bFekete commented Apr 30, 2024

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

@tenthirtyam
Copy link
Collaborator

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

@tenthirtyam tenthirtyam added needs-review Status: Pull Request Needs Review and removed do-not-merge Status: Draft, Do Not Merge labels Apr 30, 2024
@tenthirtyam tenthirtyam changed the title fix: allow datastore_cluster_id for content library clones fix: allow datastore_cluster for content library clones Apr 30, 2024
Allows specifying a `datastore_cluster_id` for `vsphere_virtual_machine` when cloning from `vsphere_content_library_item`.

Co-Authored-By: Ryan Johnson <[email protected]>
@tenthirtyam tenthirtyam force-pushed the fix/content-library-deploy-ds-cluster branch from 39c7a45 to 9dda838 Compare April 30, 2024 23:36
@tenthirtyam tenthirtyam marked this pull request as ready for review April 30, 2024 23:37
Copy link
Collaborator

@tenthirtyam tenthirtyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made some slight modifications pushed to 9dda838.

This has been tested in our environments and is good to ship.

LGTM

@tenthirtyam tenthirtyam removed the needs-review Status: Pull Request Needs Review label Apr 30, 2024
@tenthirtyam tenthirtyam modified the milestones: On Deck, v2.8.0 Apr 30, 2024
@tenthirtyam tenthirtyam merged commit 6cdc87f into hashicorp:main May 1, 2024
6 checks passed
Copy link

github-actions bot commented May 8, 2024

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!

Copy link

github-actions bot commented Jun 8, 2024

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 github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
provider Type: Provider size/xs Relative Sizing: Extra-Small
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use datastore_cluster_id with content library item
6 participants