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

[BUG] content_library block should be null when common_template_conversion is true #43

Closed
1 task done
sestegra opened this issue Sep 21, 2021 · 2 comments · Fixed by #44
Closed
1 task done
Assignees
Labels

Comments

@sestegra
Copy link
Contributor

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

Any

HashiCorp Packer

1.7.5

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

macOS Big Sur 11.6 (Intel)

Environment Details

My current Terraform workflow is using VM template stored in VM folder tree.
So, I need to convert to VM without storing it to content library.

Description

In Packer documentation (see https://www.packer.io/docs/builders/vsphere/vsphere-iso#convert_to_template)

The import doesn't work if convert_to_template is set to true

Expected Behavior

When convert_to_template is set to true, content_library_destination block should be removed.

Actual Behavior

Packer returns an error when trying to push VM template to content library.

Steps to Reproduce

Set convert_to_template is set to true

Log Fragments and Files

=> vsphere-iso.linux-ubuntu-server: Importing VM template linux-ubuntu-server-20-04-lts1632170716 to Content Library...
==> vsphere-iso.linux-ubuntu-server: Failed to import template linux-ubuntu-server-20-04-lts1632170716: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["vm-15548"],"default_message":"The provided source virtual machine ID vm-15548 is from a virtual machine template, which is not supported.","id":"com.vmware.vdcs.vmtx-main.invalid_source_vm_template_not_supported"}]}}
==> vsphere-iso.linux-ubuntu-server: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["vm-15548"],"default_message":"The provided source virtual machine ID vm-15548 is from a virtual machine template, which is not supported.","id":"com.vmware.vdcs.vmtx-main.invalid_source_vm_template_not_supported"}]}}
==> vsphere-iso.linux-ubuntu-server: Step "StepImportToContentLibrary" failed
==> vsphere-iso.linux-ubuntu-server: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?
Cancelling build after receiving interrupt
==> vsphere-iso.linux-ubuntu-server: Provisioning step had errors: Running the cleanup provisioner, if present...
==> vsphere-iso.linux-ubuntu-server: Power off VM...
==> vsphere-iso.linux-ubuntu-server: Destroying VM...
==> vsphere-iso.linux-ubuntu-server: Deleting cd_files image from remote datastore ...
Build 'vsphere-iso.linux-ubuntu-server' errored after 10 minutes 35 seconds: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["vm-15548"],"default_message":"The provided source virtual machine ID vm-15548 is from a virtual machine template, which is not supported.","id":"com.vmware.vdcs.vmtx-main.invalid_source_vm_template_not_supported"}]}}

Screenshots

No response

Additional Context

I suggest (and I can create PR for) to update code as follow

  • Set common_content_library_name default to null
  • Create dynamic block for content_library_destination
  dynamic "content_library_destination" {
    for_each = var.common_content_library_name != null ? [1] : []
    content {
      library = var.common_content_library_name
      ovf     = var.common_content_library_ovf
      destroy = var.common_content_library_destroy
    }
  }
@tenthirtyam
Copy link
Collaborator

@sestegra - yes, that's correct per the Packer docs.

That's a great idea - as it might also allow the image to be pushed to >1 publishing content library but that would require a change to the variable definition.

Please feel free to refactor, test, and submit a PR for enhancement and I'll review it for the next update.

Ryan

@tenthirtyam tenthirtyam linked a pull request Sep 21, 2021 that will close this issue
10 tasks
@github-actions
Copy link

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 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants