Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: set template name #416

Merged
merged 1 commit into from
May 9, 2024
Merged

feat: set template name #416

merged 1 commit into from
May 9, 2024

Conversation

tenthirtyam
Copy link
Collaborator

@tenthirtyam tenthirtyam commented Apr 28, 2024

Summary

Adds the ability to set the name of the of the template in the vsphere-template post-processor. If template_name is not provided, the name of the source virtual machine will be used.

Testing

General: PASS ✅

packer-plugin-vsphere1 on  feat/set-template-name [$!] via 🐹 v1.22.2 make generate
2024/04/27 21:02:44 Copying "docs" to ".docs/"
2024/04/27 21:02:44 Replacing @include '...' calls in .docs/
Compiling MDX docs in '.docs' to Markdown in '.web-docs'...


packer-plugin-vsphere1 on  feat/set-template-name [$!] via 🐹 v1.22.2 took 11.6s make build


packer-plugin-vsphere1 on  feat/set-template-name [$!] via 🐹 v1.22.2 took 3.5s make test
?       github.com/hashicorp/packer-plugin-vsphere      [no test files]
?       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common/testing       [no test files]
?       github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/examples/driver      [no test files]
?       github.com/hashicorp/packer-plugin-vsphere/version      [no test files]
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone        1.526s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/common       3.218s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/driver       5.048s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso  2.238s
ok      github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/supervisor   4.171s
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere       2.378s
ok      github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere-template      2.764s

End-to-End: ✅

No value for template_name:

build {
  sources = ["source.vsphere-iso.linux-photon"]

  post-processors {
    post-processor "vsphere-template"{
        host                = var.vsphere_endpoint
        username            = var.vsphere_username
        password            = var.vsphere_password
        insecure            = var.vsphere_insecure_connection
        datacenter          = var.vsphere_datacenter
        folder              = var.vsphere_folder
    }
  }
}
==> vsphere-iso.linux-photon: Reattaching CD-ROM devices...
==> vsphere-iso.linux-photon: Adding SATA controller...
==> vsphere-iso.linux-photon: Adding CD-ROM devices...
==> vsphere-iso.linux-photon: Exporting to Open Virtualization Format (OVF)...
==> vsphere-iso.linux-photon: Downloading linux-photon-5.0-develop-disk-0.vmdk...
==> vsphere-iso.linux-photon: Exporting linux-photon-5.0-develop-disk-0.vmdk...
==> vsphere-iso.linux-photon: Writing OVF descriptor linux-photon-5.0-develop.ovf...
==> vsphere-iso.linux-photon: Creating SHA256 manifest linux-photon-5.0-develop.mf...
==> vsphere-iso.linux-photon: Completed export to Open Virtualization Format (OVF).
    vsphere-iso.linux-photon: Closing sessions ....
==> vsphere-iso.linux-photon: Running post-processor:  (type vsphere-template)
    vsphere-iso.linux-photon (vsphere-template): Pausing momentarily to prepare for the next step...
    vsphere-iso.linux-photon (vsphere-template): Choosing datacenter...
    vsphere-iso.linux-photon (vsphere-template): Creating or checking destination folder...
    vsphere-iso.linux-photon (vsphere-template): Registering virtual machine as a template: linux-photon-5.0-develop
Build 'vsphere-iso.linux-photon' finished after 2 minutes 36 seconds.

==> Wait completed after 2 minutes 36 seconds
==> Builds finished. The artifacts of successful builds are:
--> vsphere-iso.linux-photon: linux-photon-5.0-develop

Value set for template_name to i-am-a-template:

build {
  sources = ["source.vsphere-iso.linux-photon"]

  post-processors {
    post-processor "vsphere-template"{
        template_name       = "i-am-a-template"        # <<<< --- template name
        host                = var.vsphere_endpoint
        username            = var.vsphere_username
        password            = var.vsphere_password
        insecure            = var.vsphere_insecure_connection
        datacenter          = var.vsphere_datacenter
        folder              = var.vsphere_folder
    }
  }
}
==> vsphere-iso.linux-photon: Reattaching CD-ROM devices...
==> vsphere-iso.linux-photon: Adding SATA controller...
==> vsphere-iso.linux-photon: Adding CD-ROM devices...
==> vsphere-iso.linux-photon: Exporting to Open Virtualization Format (OVF)...
==> vsphere-iso.linux-photon: Downloading linux-photon-5.0-develop-disk-0.vmdk...
==> vsphere-iso.linux-photon: Exporting linux-photon-5.0-develop-disk-0.vmdk...
==> vsphere-iso.linux-photon: Writing OVF descriptor linux-photon-5.0-develop.ovf...
==> vsphere-iso.linux-photon: Creating SHA256 manifest linux-photon-5.0-develop.mf...
==> vsphere-iso.linux-photon: Completed export to Open Virtualization Format (OVF).
    vsphere-iso.linux-photon: Closing sessions ....
==> vsphere-iso.linux-photon: Running post-processor:  (type vsphere-template)
    vsphere-iso.linux-photon (vsphere-template): Pausing momentarily to prepare for the next step...
    vsphere-iso.linux-photon (vsphere-template): Choosing datacenter...
    vsphere-iso.linux-photon (vsphere-template): Creating or checking destination folder...
    vsphere-iso.linux-photon (vsphere-template): Registering virtual machine as a template: i-am-a-template
    # ^^^ template name ^^^ 
Build 'vsphere-iso.linux-photon' finished after 2 minutes 35 seconds.

==> Wait completed after 2 minutes 35 seconds

==> Builds finished. The artifacts of successful builds are:
--> vsphere-iso.linux-photon: linux-photon-5.0-develop

Note

When using the template_name option the virtual machine will be registered with the new name; however, please note that the directory path and files will still retain the prior name. Renaming the directory and files is beyond the scope of this pull request.

Reference

Closes #397

Adds the ability to set the name of the of the template in the `vsphere-template` post-processor. If `template_name` is not provided, the name of the source virtual machine will be used.

Ref: #397

Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org
@tenthirtyam tenthirtyam force-pushed the feat/set-template-name branch from f7d9bd5 to 81d2fb7 Compare April 30, 2024 18:28
@tenthirtyam tenthirtyam marked this pull request as ready for review April 30, 2024 18:36
@tenthirtyam tenthirtyam requested a review from a team as a code owner April 30, 2024 18:36
@lbajolet-hashicorp lbajolet-hashicorp merged commit 56da2a8 into main May 9, 2024
12 checks passed
@lbajolet-hashicorp lbajolet-hashicorp deleted the feat/set-template-name branch May 9, 2024 13:46
@hashicorp hashicorp locked as resolved and limited conversation to collaborators Jun 29, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to set template name during post-processing
2 participants