( vmware-guest module) Creating VM from template and adding "No of cores per socket"

Hello,

I am deploying vms with vmware_guest module, and I need to edit “number of cores per socket” what statement should I use ?

I tried the following statement but it always give me error.

customvalues:

  • key: cpuid.coresPerSocket
    value: 2

Error :

fatal: [kuber-n-03 → localhost]: FAILED! => {“changed”: false, “msg”: “Failed t o set custom value for key=‘numvcpus’ and value=‘two’. Error was: (vmodl.fault.I nvalidArgument) {\n dynamicType = ,\n dynamicProperty = (vmodl.Dynami cProperty) ,\n msg = ‘A specified parameter was not correct. \nkey’,\n fa ultCause = ,\n faultMessage = (vmodl.LocalizableMessage) ,\n invali dProperty = u’key’\n}”}

When I set

customvalues:

  • key: cpuid.coresPerSocket
    value: two

Error:

Looks like in 2.5 you specify ‘num_cpu_cores_per_socket’ in the vmware_guest ‘hardware’ dictionary.

`

  • name: Create VM
    vmware_guest:
    hostname: somevmwareesxhost
    … other vmware_guest config …
    hardware:
    num_cpus: 4
    num_cpu_cores_per_socket: 8
    … other hardware config …
    … other vmware_guest config …

`

Yes I also tried this option but it does not impact my number of sockets. Thank you for your reply ,

Appreciate your response.

( Note I am creating vms from templates ) .

Any suggestion ?

Output from (

hardware:
memory_mb: “{{ ram_size }}”
num_cpus: “{{ cpu_nums }}”
num_cpu_cores_per_socket: 2

============= Output --============

ok: [kuber-n-03] => {
“deploy”: {
“changed”: true,
“failed”: false,
“instance”: {
“annotation”: “”,
“current_snapshot”: null,
“customvalues”: {},
“guest_tools_status”: “guestToolsNotRunning”,
“guest_tools_version”: “2147483647”,
“hw_eth0”: {
“addresstype”: “assigned”,
“ipaddresses”: null,
“label”: “Network adapter 1”,
“macaddress”: “00:50:56:b7:a8:a8”,
“macaddress_dash”: “00-50-56-b7-a8-a8”,
“summary”: “VM Network”
},
“hw_guest_full_name”: null,
“hw_guest_id”: null,
“hw_interfaces”: [
“eth0”
],
“hw_memtotal_mb”: 2048,
“hw_name”: “kuber-n-03”,
“hw_power_status”: “poweredOn”,
“hw_processor_count”: 2,
“hw_product_uuid”: “42371497-b8e6-5c9d-8859-6d73af6b9f78”,
“ipv4”: null,
“ipv6”: null,
“module_hw”: true,
“snapshots”:
}
}
}

================ End of output =============

Well, I’ll be honest, I don’t have a place to run 2.5 currently, so someone else may have to chime in. I saw that config in the source on GitHub.

I also create many VMs from templates currently with 2.4, from a base template configured with 1 CPU that is deployed to targets with multiple CPUs, vastly different network and disk, etc., and they show up fine, though I’m not adjusting cores per cpu.

Including the output from ‘-vvv’ may be helpful to others that might be reading.

If you want more sockets, you want to set num_cpus higher. If you want cores per cpu but aren’t getting them in the machine, but you should make sure that you’re running an appropriate version of vCenter and that indeed they are missing in the machine’s settings in vCenter. Could be an issue needs to be opened.

Thanks,

I think this option only work with ansible-2.5 you are right.