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

**URL:** <https://forum.ansible.com/t/vmware-guest-module-creating-vm-from-template-and-adding-no-of-cores-per-socket/27085>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [March 22, 2018, 8:05pm UTC](https://forum.ansible.com/t/vmware-guest-module-creating-vm-from-template-and-adding-no-of-cores-per-socket/27085 "2018-03-22T20:05:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![talha\_jilal](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@talha\_jilal](https://forum.ansible.com/u/talha_jilal)\
**Post date:** [March 22, 2018, 8:05pm UTC](https://forum.ansible.com/t/vmware-guest-module-creating-vm-from-template-and-adding-no-of-cores-per-socket/27085/1 "2018-03-22T20:05:47Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Nick\_Rogers](https://avatars.discourse-cdn.com/v4/letter/n/eb8c5e/32.png) [@Nick\_Rogers](https://forum.ansible.com/u/Nick_Rogers)\
**Post date:** [March 22, 2018, 8:55pm UTC](https://forum.ansible.com/t/vmware-guest-module-creating-vm-from-template-and-adding-no-of-cores-per-socket/27085/2 "2018-03-22T20:55:01Z")

</div>

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 …

`

---

<div class="post-metadata">

**Author:** ![talha\_jilal](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@talha\_jilal](https://forum.ansible.com/u/talha_jilal)\
**Post date:** [March 22, 2018, 9:02pm UTC](https://forum.ansible.com/t/vmware-guest-module-creating-vm-from-template-and-adding-no-of-cores-per-socket/27085/3 "2018-03-22T21:02:08Z")

</div>

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 =============

---

<div class="post-metadata">

**Author:** ![Nick\_Rogers](https://avatars.discourse-cdn.com/v4/letter/n/eb8c5e/32.png) [@Nick\_Rogers](https://forum.ansible.com/u/Nick_Rogers)\
**Post date:** [March 22, 2018, 9:38pm UTC](https://forum.ansible.com/t/vmware-guest-module-creating-vm-from-template-and-adding-no-of-cores-per-socket/27085/4 "2018-03-22T21:38:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![talha\_jilal](https://avatars.discourse-cdn.com/v4/letter/t/ea666f/32.png) [@talha\_jilal](https://forum.ansible.com/u/talha_jilal)\
**Post date:** [March 23, 2018, 2:20am UTC](https://forum.ansible.com/t/vmware-guest-module-creating-vm-from-template-and-adding-no-of-cores-per-socket/27085/5 "2018-03-23T02:20:36Z")

</div>

Thanks,

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