eran meiri
eran meiri

Reputation: 1518

vagrant - multiple cores on vagrant provisioner

I am using vagrant for my automation of machines in vmware.

until now I have created machines with 2 CPU and it worked great.

now I need to create a machine with 8 cores and I get this failure message:

GenericVmConfigFault: The virtual machine cannot be powered on because the number of virtual CPUs is not a multiple of the number of cores per socket configured in the virtual machine.

I know that the rate should be 2 CPU per socket , but How can I configure the amount of sockets ?

this is the code sample:

mach.vm.provider :vsphere do |vsphere|  
                vsphere.host = 'lab6'                            
                vsphere.compute_resource_name = 'lab6'                       
                vsphere.template_name = 'RH74-Template'      
                vsphere.name = 'serv4'                                       
                vsphere.user = 'xxxxxxxx'                                    
                vsphere.password = 'xxxxxxxx'                            
                vsphere.insecure = true  
                vsphere.memory_mb = 51200
                vsphere.cpu_count = 8         
        end

thanks

Upvotes: 1

Views: 1602

Answers (1)

Patrick
Patrick

Reputation: 3250

Configuring the cores per socket is a VMX configuration in VMWare. Assuming you have the VMWare provider installed properly in Vagrant, within your Vagrant.configure() block, you can pass in VMX configurations as a Hash set into the box. Configure your settings in there. The two keys you're interested in are:

cpuid.coresPerSocket numvcpus

Within VMWare's GUI, there are "number of processors" and "number of cores per processor". The two are multiplied together to get "numvcpus", so "numvcpus/cpuid.coresPerSocker" must be a whole number, which is the error you're getting. Make your life easier, and just set that VMX value to 1 :)

EDIT to add example:

config.vm.provider "vmware_desktop" do |v|
  v.vmx["cpuid.coresPerSocket"]  = "1"
  v.vmx["numvcpus"] = "4"
end

This will create a VMWare box that acts as a 4 core CPU (with 1 core per socket). Note that VMX configuration is the last step in the process according to Vagrant's documentation, so if you set numvcpus, it will override vagrant's CPU configurations even within the same vagrant file. coresPerSocket will do the same, so you should essentially use this instead of vagrant's CPU commands if you're having issues with it.

Note: VMX configurations are explicitly NOT backwards compatible according to VMWare's documentation. They are undocumented. The best way to determine the setting you need if the above documentation is not working for you is to craft a box by hand using the version of VMWare you're using then open the VMX file that is created and find the value you input. All values in the VMX file are key-value, and can be inserted/modified by using the above pattern. If you want to remove a value, set the value it "nil" (without the quotes).

Upvotes: 2

Related Questions