vmware-samples / packer-examples-for-vsphere

Packer Examples for vSphere
https://vmware-samples.github.io/packer-examples-for-vsphere/
Other
829 stars 326 forks source link

Builds may fail when using `iso_url` and other `iso_*` variables remain defined #343

Closed PabloRapidScale closed 1 year ago

PabloRapidScale commented 2 years ago

Code of Conduct

Community Note

Project Version

main

VMware vSphere

7.0.3d

HashiCorp Packer

1.8.4

HashiCorp Packer Plugin for VMware vSphere

1.1.0

Guest Operating System

Debian 11.5, Windows 2022, Windows 2019, Windows 10

Environment Details

No response

Description

Builds may fail if using iso_url while leaving the iso_path and iso_file options filled in.

Expected Behavior

Per Readme "The iso_url variable takes presedence over any other iso_* variables." i.e. when adding a URL location it should ignore the rest of the iso_* entries. However, if you add a value to the iso_url variable it will do what it normally would do like download the iso, put it in the cache, upload it, etc. but it will also mount the iso_file as an additional disk object causing different OS versions to have to account for an additional unexpected disc.

Actual Behavior

You will end up with an extra disc device and an iso attached to the specified iso_path and iso_file location regardless if the actual iso file or path exists. Depending on the OS you're deploying they may act differently in each of the scenarios below.

Steps to Reproduce

Windows 2019

// Removable Media Settings
iso_url            = "https://software-download.microsoft.com/download/pr/17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso"
iso_path           = "iso/windows/server"
iso_file           = "en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso"
iso_checksum_type  = "sha1"
iso_checksum_value = "3022424f777b66a698047ba1c37812026b9714c5"

Windows 2022

// Removable Media Settings
iso_url            = "https://software-static.download.prss.microsoft.com/sg/download/888969d5-f34g-4e03-ac9d-1f9786c66749/SERVER_EVAL_x64FRE_en-us.iso"
iso_path           = "iso/windows/server"
iso_file           = "en-us_windows_server_2022_updated_sep_2022_x64_dvd_44ee9450.iso"
iso_checksum_type  = "sha256"
iso_checksum_value = "3E4FA6D8507B554856FC9CA6079CC402DF11A8B79344871669F0251535255325"

Debian 11.5

// Removable Media Settings
iso_url            = "http://cdimage.debian.org/cdimage/release/11.5.0/amd64/iso-cd/debian-11.5.0-amd64-netinst.iso"
iso_path           = "iso/linux/debian"
iso_file           = "debian-11.5.0-amd64-netinst.iso"
iso_checksum_type  = "sha512"
iso_checksum_value = "6a6607a05d57b7c62558e9c462fe5c6c04b9cfad2ce160c3e9140aa4617ab73aff7f5f745dfe51bbbe7b33c9b0e219a022ad682d6c327de0e53e40f079abf66a"

Log Fragments and Files

2022/11/09 00:10:09 ui: ==> vsphere-iso.windows-server-standard-core: Mounting ISO images...
2022/11/09 00:10:09 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:09 Check if ISO path is a Content Library path
2022/11/09 00:10:10 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:10 ISO path not identified as a Content Library path
2022/11/09 00:10:10 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:10 Using [Datastore] packer_cache//61381f58cd37c3a9800f232e47a7438fa3e98b62.iso as the datastore path
2022/11/09 00:10:10 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:10 Creating CD-ROM on controller '&{{{} 15000 0xc0003a11c0 <nil> <nil> <nil> 100 0xc000b5d7fc} 0 []}' with iso '[Datastore] packer_cache//61381f58cd37c3a9800f232e47a7438fa3e98b62.iso'
2022/11/09 00:10:10 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:10 Check if ISO path is a Content Library path
2022/11/09 00:10:10 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:10 ISO path not identified as a Content Library path
2022/11/09 00:10:10 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:10 Using [Datastore] iso/windows/server/en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso as the datastore path
2022/11/09 00:10:10 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:10 Creating CD-ROM on controller '&{{{} 15000 0xc0009cc0c0 <nil> <nil> <nil> 100 0xc0007e5d0c} 0 [16000]}' with iso '[Datastore] iso/windows/server/en-us_windows_server_2019_updated_aug_2021_x64_dvd_a6431a28.iso'
2022/11/09 00:10:11 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:11 Check if ISO path is a Content Library path
2022/11/09 00:10:12 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:12 ISO path not identified as a Content Library path
2022/11/09 00:10:12 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:12 Using [] /vmimages/tools-isoimages/windows.iso as the datastore path
2022/11/09 00:10:12 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:12 Creating CD-ROM on controller '&{{{} 15000 0xc000a2a200 <nil> <nil> <nil> 100 0xc00095688c} 0 [16000 16001]}' with iso '[] /vmimages/tools-isoimages/windows.iso'
2022/11/09 00:10:12 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:12 Check if ISO path is a Content Library path
2022/11/09 00:10:12 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:12 ISO path not identified as a Content Library path
2022/11/09 00:10:12 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:12 Using [Datastore] packer_cache//packer1599107003.iso as the datastore path
2022/11/09 00:10:12 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:12 Creating CD-ROM on controller '&{{{} 15000 0xc000c26620 <nil> <nil> <nil> 100 0xc000c1f05c} 0 [16000 16001 16002]}' with iso '[Datastore] packer_cache//packer1599107003.iso'
2022/11/09 00:10:12 ui: ==> vsphere-iso.windows-server-standard-core: Adding configuration parameters...
2022/11/09 00:10:13 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:13 No floppy files specified. Floppy disk will not be made.
2022/11/09 00:10:13 ui: ==> vsphere-iso.windows-server-standard-core: Set boot order...
2022/11/09 00:10:13 ui: ==> vsphere-iso.windows-server-standard-core: Power on VM...
2022/11/09 00:10:13 ui: ==> vsphere-iso.windows-server-standard-core: Waiting 2s for boot...
2022/11/09 00:10:15 ui: ==> vsphere-iso.windows-server-standard-core: Typing boot command...
2022/11/09 00:10:15 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:15 Special code '<spacebar>' found, replacing with: CodeSpacebar
2022/11/09 00:10:15 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:10:15 [INFO] Waiting for IP, up to total timeout: 20m0s, settle timeout: 5s
2022/11/09 00:10:15 ui: ==> vsphere-iso.windows-server-standard-core: Waiting for IP...
2022/11/09 00:30:15 ui error: ==> vsphere-iso.windows-server-standard-core: Timeout waiting for IP.
2022/11/09 00:30:15 ui: ==> vsphere-iso.windows-server-standard-core: Power off VM...
2022/11/09 00:30:16 ui: ==> vsphere-iso.windows-server-standard-core: Destroying VM...
2022/11/09 00:30:16 ui: ==> vsphere-iso.windows-server-standard-core: Deleting cd_files image from remote datastore ...
2022/11/09 00:30:17 packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64 plugin: 2022/11/09 00:30:17 Deleting CD disk: /tmp/packer1599107003.iso
2022/11/09 00:30:17 [INFO] (telemetry) ending vsphere-iso.windows-server-standard-core
2022/11/09 00:30:17 ui error: Build 'vsphere-iso.windows-server-standard-core' errored after 20 minutes 10 seconds: Timeout waiting for IP.
2022/11/09 00:30:17 ui: 
==> Wait completed after 20 minutes 10 seconds
2022/11/09 00:30:17 machine readable: error-count []string{"1"}
2022/11/09 00:30:17 ui error: 
==> Some builds didn't complete successfully and had errors:
2022/11/09 00:30:17 machine readable: vsphere-iso.windows-server-standard-core,error []string{"Timeout waiting for IP."}
2022/11/09 00:30:17 ui error: --> vsphere-iso.windows-server-standard-core: Timeout waiting for IP.
2022/11/09 00:30:17 ui: 
==> Builds finished but no artifacts were created.
2022/11/09 00:30:17 [INFO] (telemetry) Finalizing.
2022/11/09 00:30:17 waiting for all plugin processes to complete...
2022/11/09 00:30:17 /usr/bin/packer: plugin process exited
2022/11/09 00:30:17 /usr/bin/packer: plugin process exited
2022/11/09 00:30:17 /usr/bin/packer: plugin process exited
2022/11/09 00:30:17 /home/pablo/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.0_x5.0_linux_amd64: plugin process exited
2022/11/09 00:30:17 /home/pablo/.config/packer/plugins/github.com/rgl/windows-update/packer-plugin-windows-update_v0.14.1_x5.0_linux_amd64: plugin process exited

Screenshots

2022-11-08 16_33_09-vSphere - windows-server-2019-standard-core-v22 11 - Summary 2022-11-08 16_33_50-vSphere - windows-server-2019-standard-core-v22 11 - Summary 2022-11-08 16_54_58-windows-server-2019-standard-core-v22 11 - VMware Remote Console

Additional Context

No response

github-actions[bot] commented 2 years ago

Hello, PabloRapidScale! 🖐

Thank you for your submitting an issue for the project. We will respond soon.

If you want to contribute to this project, please review the contributing guidelines.

tenthirtyam commented 2 years ago

Please note that I have properly formatted the Markdown for the variable and log content of the issue description.

tenthirtyam commented 2 years ago

Try the following and let me know the results:

Debian Example:

// Removable Media Settings
iso_url            = "http://cdimage.debian.org/cdimage/release/11.5.0/amd64/iso-cd/debian-11.5.0-amd64-netinst.iso"
iso_path           = ""
iso_file           = ""
iso_checksum_type  = "sha512"
iso_checksum_value = "6a6607a05d57b7c62558e9c462fe5c6c04b9cfad2ce160c3e9140aa4617ab73aff7f5f745dfe51bbbe7b33c9b0e219a022ad682d6c327de0e53e40f079abf66a"

However, it will likely still attach a CD-ROM to a datastore with no attached media.

tenthirtyam commented 2 years ago

To work around this issue, the project will likely need to incorporate some logic in the HCL config to support one or the other methods, or remove support for iso_url method.

PabloRapidScale commented 2 years ago

Try the following and let me know the results:

Debian Example:

// Removable Media Settings
iso_url            = "http://cdimage.debian.org/cdimage/release/11.5.0/amd64/iso-cd/debian-11.5.0-amd64-netinst.iso"
iso_path           = ""
iso_file           = ""
iso_checksum_type  = "sha512"
iso_checksum_value = "6a6607a05d57b7c62558e9c462fe5c6c04b9cfad2ce160c3e9140aa4617ab73aff7f5f745dfe51bbbe7b33c9b0e219a022ad682d6c327de0e53e40f079abf66a"

However, it will likely still attach a CD-ROM to a datastore with no attached media.

This worked, it just makes it fall into scenario 3 I mentioned in my original post. As you noted It still mounts an additional CD with no attached media. I imagine this would still fail with Windows as it will still throw the drive letters out of order causing the autounattend.xml to not be accurate anymore.

tenthirtyam commented 2 years ago

I've placed this on the backlog and will review this option at a later time to see if there is a more elegant method to toggle this feature. For now, the projects defaults works as intended.

If you think of a method, contributions are welcome following the CONTRIBUTING.md.

tenthirtyam commented 1 year ago

Based on further review and testing of options, I will be reverting pull request #249 for enhancement #235 and this project will remove support for iso_url.

github-actions[bot] commented 1 year ago

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.