-
Notifications
You must be signed in to change notification settings - Fork 108
error removing cdrom prior to reattaching: invalid number: n must be between 0 and 0 #393
Copy link
Copy link
Closed
Copy link
Labels
Description
Overview of the Issue
Packer build for a given Windows server build no longer works. I believe the 1.2.5 refactoring release created this issue, it only became apparent once #386 was corrected. Now the build finishes, with the error
==> windows2022.vsphere-iso.windows2022: Reattaching CD-ROM devices...
==> windows2022.vsphere-iso.windows2022: error removing cdrom prior to reattaching: invalid number: n must be between 0 and 0
==> windows2022.vsphere-iso.windows2022: Step "StepReattachCDRom" failed
==> windows2022.vsphere-iso.windows2022: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)? a
==> windows2022.vsphere-iso.windows2022: error removing cdrom prior to reattaching: invalid number: n must be between 0 and 0
==> windows2022.vsphere-iso.windows2022: Step "StepReattachCDRom" failed, aborting...
Version 1.2.4 and older:
D: = Windows Install media ISO
E: = VMware Tools ISO
Version 1.2.6:
D: = VMware Tools ISO
E: = Windows Install media ISO
Reproduction Steps
Works as per previous version: KO Packer build where
packer {
required_plugins {
ansible = {
version = ">= 1.1.1"
source = "github.com/hashicorp/ansible"
}
vsphere = { # added due to https://www.hashicorp.com/blog/announcing-the-removal-of-bundled-plugins-in-hashicorp-packer
version = "= 1.2.4"
source = "github.com/hashicorp/vsphere"
}
}
}
Change to 1.2.6 - Build will timeout waiting for VMTools to install
packer {
required_plugins {
ansible = {
version = ">= 1.1.1"
source = "github.com/hashicorp/ansible"
}
vsphere = { # added due to https://www.hashicorp.com/blog/announcing-the-removal-of-bundled-plugins-in-hashicorp-packer
version >= "= 1.2.6"
source = "github.com/hashicorp/vsphere"
}
}
}
Packer Version
1.8.3
Plugin Version and Builders
Please provide the plugin version.
1.2.6
Please select the builder.
- []
vsphere-iso
VMware vSphere Version
Please provide the VMware vSphere version.
vCenter Server 7.0 Update 3o
VMware ESXi 7.0 Update 3g
Guest Operating System
Windows 2022 & 2019
Simplified Packer Buildfile
source "vsphere-iso" "windows2022" {
// https://github.com/vmware-samples/packer-examples-for-vsphere/blob/main/builds/windows/server/2016/windows-server.pkr.hcl
....
storage {
disk_size = var.windows2022_vm_disk_sizeMB
disk_controller_index = 0
disk_thin_provisioned = true
}
network_adapters {
network = var.vcenter_network
network_card = "vmxnet3"
}
cdrom_type = var.windows2022_vm_cdrom_type
remove_cdrom = true
reattach_cdroms = 1
// vSphere template settings
convert_to_template = true
export {
force = true
output_directory = var.ovfFile_location
}
create_snapshot = false
// OS Configuration
guest_os_type = "${var.windows2022_vm_guest_os_type}"
notes = "Default User: ${var.winrm_username}\nBuilt by Packer @ {{isotime \"2006-01-02 03:04\"}}."
// Removable Media Settings
iso_url = "${var.windows_artifcatory}${var.windows2022_iso}"
iso_target_path = "${var.PACKER_CACHE_DIR}/${var.windows2022_iso}"
iso_checksum = var.windows2022_checksum
iso_paths = ["[] /vmimages/tools-isoimages/${var.windows2022_os_family}.iso"]
floppy_files = [
"${var.os_config_root}/${var.windows2022_os_family}/${var.windows2022_scripts_folder}/"
]
floppy_content = {
"autounattend.xml" = templatefile("${var.os_config_root}/${var.windows2022_os_family}/${var.windows2022_scripts_folder}/${var.windows2022_vm_firmware}_autounattend.pkrtpl.hcl", {
vm_guest_os_language = var.windows2022_vm_guest_os_language
vm_guest_os_keyboard = var.windows2022_vm_guest_os_keyboard
vm_guest_os_timezone = var.windows2022_vm_guest_os_timezone
})
}
// Boot and Provisioning Settings
// http_port_min = var.common_http_port_min
// http_port_max = var.common_http_port_max
boot_order = var.windows2022_vm_boot_order
boot_wait = var.windows2022_vm_boot_wait
boot_command = var.windows2022_vm_boot_command
Set the env var PACKER_LOG=1 for maximum log detail.
Reactions are currently unavailable