Closed hc-github-team-packer closed 1 year ago
@memtaus - please consider including a redacted Gist with a sample of the configuration.
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
Per the docs it's cpu_cores
, not cpu_per_socket
. Hence the error of unknown configuration key
.
"CPUs": "4",
"cores_per_socket": "2",
"ram": "16384",
to
"CPUs": "4",
"cpu_cores": "2",
"ram": "16384",
cc @nywilken
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
As my original post states, I tried cpu_cores and got the same error. I then tried the value in the Gist and another value that was discussed in the older issue I linked in my post. They all produce an "unknown configuration key" for that key.
It's possibly a bug
, but it is certainly mapped to cpu_cores
in the code shared between the builders..
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
Issue https://github.com/hashicorp/packer/issues/7190 was for the Packer Plugin for VMware (Fusion, Workstation...) ; not the Packer Plugin for VMware vSphere.
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
I've verified that it works in a HCL examples for both the vsphere-iso
and vsphere-clone
builders.
Here's the high-level vsphere-clone
configuration I created:
/*
DESCRIPTION:
Ubuntu Server 22.04 LTS cloned template using the Packer Builder for VMware vSphere (vsphere-clone).
*/
// BLOCK: packer
// The Packer configuration.
packer {
required_version = ">= 1.8.2"
required_plugins {
vsphere = {
version = ">= v1.0.6"
source = "github.com/hashicorp/vsphere"
}
}
}
// BLOCK: locals
// Defines the local variables.
locals {
build_by = "Built by: HashiCorp Packer ${packer.version}"
build_date = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp())
build_version = formatdate("YY.MM", timestamp())
build_description = "Version: v${local.build_version}\nBuilt on: ${local.build_date}\n${local.build_by}"
manifest_date = formatdate("YYYY-MM-DD hh:mm:ss", timestamp())
manifest_path = "${path.cwd}/manifests/"
manifest_output = "${local.manifest_path}${local.manifest_date}.json"
ovf_export_path = "${path.cwd}/artifacts/${local.vm_name}"
template_name = "${var.vm_guest_os_family}-${var.vm_guest_os_name}-${var.vm_guest_os_version}-v${local.build_version}"
vm_name = "${local.template_name}-clone"
}
source "vsphere-clone" "linux-ubuntu-clone" {
// vCenter Server Endpoint Settings and Credentials
vcenter_server = var.vsphere_endpoint
username = var.vsphere_username
password = var.vsphere_password
insecure_connection = var.vsphere_insecure_connection
// vSphere Settings
datacenter = var.vsphere_datacenter
cluster = var.vsphere_cluster
datastore = var.vsphere_datastore
folder = var.vsphere_folder
// Virtual Machine Settings
template = local.template_name
vm_name = local.vm_name
firmware = var.vm_firmware
CPUs = var.vm_cpu_count
cpu_cores = var.vm_cpu_cores
CPU_hot_plug = var.vm_cpu_hot_add
RAM = var.vm_mem_size
RAM_hot_plug = var.vm_mem_hot_add
cdrom_type = var.vm_cdrom_type
disk_controller_type = var.vm_disk_controller_type
storage {
disk_size = var.vm_disk_size
disk_thin_provisioned = var.vm_disk_thin_provisioned
}
network = var.vsphere_network
remove_cdrom = var.common_remove_cdrom
tools_upgrade_policy = var.common_tools_upgrade_policy
notes = local.build_description
// Removable Media Sttings
ip_wait_timeout = var.common_ip_wait_timeout
shutdown_command = "echo '${var.build_password}' | sudo -S -E shutdown -P now"
shutdown_timeout = var.common_shutdown_timeout
// Communicator Settings and Credentials
communicator = "ssh"
ssh_proxy_host = var.communicator_proxy_host
ssh_proxy_port = var.communicator_proxy_port
ssh_proxy_username = var.communicator_proxy_username
ssh_proxy_password = var.communicator_proxy_password
ssh_username = var.build_username
ssh_password = var.build_password
ssh_port = var.communicator_port
ssh_timeout = var.communicator_timeout
// Template and Content Library Settings
convert_to_template = var.common_template_conversion
dynamic "content_library_destination" {
for_each = var.common_content_library_name != null ? [1] : []
content {
library = var.common_content_library_name
description = local.build_description
ovf = var.common_content_library_ovf
destroy = var.common_content_library_destroy
skip_import = var.common_content_library_skip_export
}
}
// OVF Export Settings
dynamic "export" {
for_each = var.common_ovf_export_enabled == true ? [1] : []
content {
name = local.vm_name
force = var.common_ovf_export_overwrite
options = [
"extraconfig"
]
output_directory = local.ovf_export_path
}
}
}
build {
sources = ["source.vsphere-clone.linux-ubuntu-clone"]
}
/*
DESCRIPTION:
Ubuntu Server 22.04 LTS cloned template variables used by the Packer Plugin for VMware vSphere (vsphere-clone).
*/
// Guest Operating System Metadata
vm_guest_os_language = "en_US"
vm_guest_os_keyboard = "us"
vm_guest_os_timezone = "UTC"
vm_guest_os_family = "linux"
vm_guest_os_name = "ubuntu"
vm_guest_os_version = "22.04lts"
// Virtual Machine Guest Operating System Setting
vm_guest_os_type = "ubuntu64Guest"
// Virtual Machine Hardware Settings
vm_firmware = "efi-secure"
vm_cdrom_type = "sata"
vm_cpu_count = 16
vm_cpu_cores = 2
vm_cpu_hot_add = false
vm_mem_size = 2048
vm_mem_hot_add = false
vm_disk_size = 40960
vm_disk_controller_type = ["pvscsi"]
vm_disk_thin_provisioned = true
vm_network_card = "vmxnet3"
// Boot Settings
vm_boot_order = "disk,cdrom"
vm_boot_wait = "5s"
// Communicator Settings
communicator_port = 22
communicator_timeout = "30m"
Result:
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
Is it still not working for you?
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
I've been tied up with other projects I got sucked into. But unless it's a versioning issue, I don't see anything here that would make me expect different results than I'm already getting. Using cpu_cores
isn't working in json, and I don't have bandwidth to rework the templates in HCL as an experiment.
Thanks for the reply - I can certainly understood.
In the meantime, I'll leave any remaining investigation / triage to the maintainer(s) or other community members.
Recommend: question
, needs-triage
cc @nywilken
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
You don't necessarily need to rework the templates as an experiment.
Consider using the vmware-samples/packer-examples-for-vsphere project to perform a test which includes the used cpu_cores
by default.
This certainty works with HCL and should certainly work with JSON.
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
Checking in for an update to see if you've tried the recommended test.
If there is no further activity on this question
within the next 30 days it will be closed.
Ryan Johnson Senior Staff Solutions Architect | Product Engineering @ VMware, Inc.
Marking this issue as closed. If this issue is reproducible with the latest version of the plugin', please create a new issue linking back to this one for added context.
Thank you!
This issue was originally opened by @memtaus in https://github.com/hashicorp/packer/issues/11952 and has been migrated to this repository. The original issue description is below.
I'm using the vsphere-clone builder to create a template that requires the number of cores per socket to be set. I've tried using "cpu_cores" as the packer-template.json configuration key, as documented here. I've also tried both keys ("cores" and "cores_per_socket") that were discussed in this issue. All of them produce an "unknown configuration key" error.