Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Overview of the Issue
I'm creating an image with packer via vcenter (vsphere-iso). Till here, everything is working, but on the end, when I use post-processor "vsphere" and post-processor "vsphere-template" to add the image to other vcenters, I'm getting an error.
Only it works when I add "-template" on the name (commented on the code)
Reproduction Steps
2026/06/15 08:30:27 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Opening OVA source: /tmp/images/KN-RHEL9-2026.07.ova�[0m
2026/06/15 08:30:27 ui: �[1;32m==> vsphere-iso.rhel (vsphere): The manifest validates�[0m
2026/06/15 08:30:29 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Opening VI target: vi://sv.EMEA.gisosauto%40corp.int.kn@vcenter-dcamer.int.kn:443/DCAMER/host/203_us_ngk_s_lnx�[0m
2026/06/15 08:31:54 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Deploying to VI: vi://sv.EMEA.gisosauto%40corp.int.kn@vcenter-dcamer.int.kn:443/DCAMER/host/203_us_ngk_s_lnx�[0m
2026/06/15 08:32:58 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Transfer Completed�[0m
2026/06/15 08:33:01 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Completed successfully�[0m
2026/06/15 08:33:01 ui: �[1;32m==> vsphere-iso.rhel: Running post-processor: (type vsphere-template)�[0m
2026/06/15 08:33:01 packer-plugin-vsphere_v2.1.2_x5.0_linux_amd64 plugin: 2026/06/15 08:33:01 [DEBUG] - common: sending ConfigSpec as protobuf
2026/06/15 08:33:01 [DEBUG] - common: receiving ConfigSpec as protobuf
2026/06/15 08:33:01 ui: �[1;32m==> vsphere-iso.rhel (vsphere-template): Pausing momentarily to prepare for the next step...�[0m
2026/06/15 08:33:11 ui: �[1;32m==> vsphere-iso.rhel (vsphere-template): Choosing datacenter...�[0m
2026/06/15 08:33:12 ui: �[1;32m==> vsphere-iso.rhel (vsphere-template): Creating or checking destination folder...�[0m
2026/06/15 08:33:12 ui error: �[1;31m==> vsphere-iso.rhel (vsphere-template): template 'KN-RHEL9-2026.07' already exists. Set 'override = true' to replace existing templates�[0m
2026/06/15 08:33:12 packer-plugin-vsphere_v2.1.2_x5.0_linux_amd64 plugin: 2026/06/15 08:33:12 error: template 'KN-RHEL9-2026.07' already exists. Set 'override = true' to replace existing templates
Packer version
Packer version: 1.12.0 [go1.22.9 linux amd64]
Simplified Packer Template
source "vsphere-iso" "rhel" {
vcenter_server = var.vmware_server_emea
username = local.vmware_username
password = local.vmware_password
datacenter = var.vmware_datacenter_emea
cluster = var.vmware_cluster_emea
datastore = var.vmware_datastore
network_adapters {
network = var.vmware_vm_network_emea
network_card = var.vm_network_card
}
folder = var.vmware_vm_folder
remote_cache_overwrite = var.vmware_overwrite
iso_url = "https://s3.int.kn/denot-packer-image-artifacts/packer-image-artifacts/ISO/rhel-${var.vm_os_version}-dvd.iso"
iso_checksum = var.iso_checksum
guest_os_type = var.vm_os_guest
vm_name = "${local.vm_name}"
cd_content = var.vm_data_source == "disk" ? local.data_source_content : null
CPUs = var.vm_hs_cpus
RAM = var.vm_hs_mem_size
firmware = "efi"
storage {
disk_size = var.vm_hs_disk_size
}
disk_controller_type = [var.vm_hs_disk_adapter_type]
boot_wait = var.vm_boot_wait
boot_command = [
// This sends the "up arrow" key, typically used to navigate through boot menu options.
"",
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
"e",
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
"",
// This types the string "text" followed by the value of the 'data_source_command' local variable.
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
" text ${local.data_source_command}",
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
"x"
]
communicator = "ssh"
insecure_connection = var.communicator_insecure_connection
ssh_username = local.gosadmin_username
ssh_agent_auth = true
ssh_wait_timeout = var.communicator_timeout
convert_to_template = true
remove_cdrom = true
vm_version = 19
}
build {
sources = ["sources.vsphere-iso.rhel"]
post-processors {
post-processor "artifice" {
files = ["/tmp/images/${local.vm_name}.ova"]
keep_input_artifact = true
}
post-processor "vsphere" {
# vm_name = "${local.vm_name}-template"
vm_name = "${local.vm_name}"
host = var.vmware_host_amer
username = local.vmware_username
password = local.vmware_password
datacenter = var.vmware_datacenter_amer
cluster = var.vmware_cluster_amer
datastore = var.vmware_datastore
insecure = var.vmware_insecure
vm_folder = var.vmware_vm_folder
vm_network = var.vmware_vm_network_amer
keep_input_artifact = var.vmware_keep_input_artifact
overwrite = var.vmware_overwrite
}
post-processor "vsphere-template" {
host = var.vmware_host_amer
username = local.vmware_username
password = local.vmware_password
insecure = var.vmware_insecure
datacenter = var.vmware_datacenter_amer
folder = var.vmware_vm_folder
template_name = local.vm_name
}
post-processor "vsphere" {
vm_name = "${local.vm_name}"
# vm_name = "${local.vm_name}-template"
host = var.vmware_host_apac
username = local.vmware_username
password = local.vmware_password
datacenter = var.vmware_datacenter_apac
cluster = var.vmware_cluster_apac
datastore = var.vmware_datastore
insecure = var.vmware_insecure
vm_folder = var.vmware_vm_folder
vm_network = var.vmware_vm_network_apac
keep_input_artifact = var.vmware_keep_input_artifact
overwrite = var.vmware_overwrite
}
post-processor "vsphere-template" {
host = var.vmware_host_apac
username = local.vmware_username
password = local.vmware_password
insecure = var.vmware_insecure
datacenter = var.vmware_datacenter_apac
folder = var.vmware_vm_folder
template_name = local.vm_name
}
}
}
Operating system and Environment details
It happens on RHEL8/9/10 and Windows Server 2016/2019/2022/2025.
The problem is not the image itself is after when converting the image to template.
Community Note
Overview of the Issue
I'm creating an image with packer via vcenter (vsphere-iso). Till here, everything is working, but on the end, when I use post-processor "vsphere" and post-processor "vsphere-template" to add the image to other vcenters, I'm getting an error.
Only it works when I add "-template" on the name (commented on the code)
Reproduction Steps
2026/06/15 08:30:27 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Opening OVA source: /tmp/images/KN-RHEL9-2026.07.ova�[0m
2026/06/15 08:30:27 ui: �[1;32m==> vsphere-iso.rhel (vsphere): The manifest validates�[0m
2026/06/15 08:30:29 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Opening VI target: vi://sv.EMEA.gisosauto%40corp.int.kn@vcenter-dcamer.int.kn:443/DCAMER/host/203_us_ngk_s_lnx�[0m
2026/06/15 08:31:54 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Deploying to VI: vi://sv.EMEA.gisosauto%40corp.int.kn@vcenter-dcamer.int.kn:443/DCAMER/host/203_us_ngk_s_lnx�[0m
2026/06/15 08:32:58 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Transfer Completed�[0m
2026/06/15 08:33:01 ui: �[1;32m==> vsphere-iso.rhel (vsphere): Completed successfully�[0m
2026/06/15 08:33:01 ui: �[1;32m==> vsphere-iso.rhel: Running post-processor: (type vsphere-template)�[0m
2026/06/15 08:33:01 packer-plugin-vsphere_v2.1.2_x5.0_linux_amd64 plugin: 2026/06/15 08:33:01 [DEBUG] - common: sending ConfigSpec as protobuf
2026/06/15 08:33:01 [DEBUG] - common: receiving ConfigSpec as protobuf
2026/06/15 08:33:01 ui: �[1;32m==> vsphere-iso.rhel (vsphere-template): Pausing momentarily to prepare for the next step...�[0m
2026/06/15 08:33:11 ui: �[1;32m==> vsphere-iso.rhel (vsphere-template): Choosing datacenter...�[0m
2026/06/15 08:33:12 ui: �[1;32m==> vsphere-iso.rhel (vsphere-template): Creating or checking destination folder...�[0m
2026/06/15 08:33:12 ui error: �[1;31m==> vsphere-iso.rhel (vsphere-template): template 'KN-RHEL9-2026.07' already exists. Set 'override = true' to replace existing templates�[0m
2026/06/15 08:33:12 packer-plugin-vsphere_v2.1.2_x5.0_linux_amd64 plugin: 2026/06/15 08:33:12 error: template 'KN-RHEL9-2026.07' already exists. Set 'override = true' to replace existing templates
Packer version
Packer version: 1.12.0 [go1.22.9 linux amd64]
Simplified Packer Template
source "vsphere-iso" "rhel" {
vcenter_server = var.vmware_server_emea
username = local.vmware_username
password = local.vmware_password
datacenter = var.vmware_datacenter_emea
cluster = var.vmware_cluster_emea
datastore = var.vmware_datastore
network_adapters {
network = var.vmware_vm_network_emea
network_card = var.vm_network_card
}
folder = var.vmware_vm_folder
remote_cache_overwrite = var.vmware_overwrite
iso_url = "https://s3.int.kn/denot-packer-image-artifacts/packer-image-artifacts/ISO/rhel-${var.vm_os_version}-dvd.iso"
iso_checksum = var.iso_checksum
guest_os_type = var.vm_os_guest
vm_name = "${local.vm_name}"
cd_content = var.vm_data_source == "disk" ? local.data_source_content : null
CPUs = var.vm_hs_cpus
RAM = var.vm_hs_mem_size
firmware = "efi"
storage {
disk_size = var.vm_hs_disk_size
}
disk_controller_type = [var.vm_hs_disk_adapter_type]
boot_wait = var.vm_boot_wait
boot_command = [
// This sends the "up arrow" key, typically used to navigate through boot menu options.
"",
// This sends the "e" key. In the GRUB boot loader, this is used to edit the selected boot menu option.
"e",
// This sends two "down arrow" keys, followed by the "end" key, and then waits. This is used to navigate to a specific line in the boot menu option's configuration.
"",
// This types the string "text" followed by the value of the 'data_source_command' local variable.
// This is used to modify the boot menu option's configuration to boot in text mode and specify the kickstart data source configured in the common variables.
" text ${local.data_source_command}",
// This sends the "enter" key, waits, turns on the left control key, sends the "x" key, and then turns off the left control key. This is used to save the changes and exit the boot menu option's configuration, and then continue the boot process.
"x"
]
communicator = "ssh"
insecure_connection = var.communicator_insecure_connection
ssh_username = local.gosadmin_username
ssh_agent_auth = true
ssh_wait_timeout = var.communicator_timeout
convert_to_template = true
remove_cdrom = true
vm_version = 19
}
build {
sources = ["sources.vsphere-iso.rhel"]
post-processors {
post-processor "artifice" {
files = ["/tmp/images/${local.vm_name}.ova"]
keep_input_artifact = true
}
}
}
Operating system and Environment details
It happens on RHEL8/9/10 and Windows Server 2016/2019/2022/2025.
The problem is not the image itself is after when converting the image to template.