diff --git a/lib/ansible/modules/cloud/vmware/vsphere_guest.py b/lib/ansible/modules/cloud/vmware/vsphere_guest.py index c523af4232b..009af7058ae 100644 --- a/lib/ansible/modules/cloud/vmware/vsphere_guest.py +++ b/lib/ansible/modules/cloud/vmware/vsphere_guest.py @@ -1360,6 +1360,8 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, if vm_disk: disk_num = 0 disk_key = 0 + bus_num = 0 + disk_ctrl = 1 for disk in sorted(vm_disk): try: datastore = vm_disk[disk]['datastore'] @@ -1382,6 +1384,16 @@ def create_vm(vsphere_client, module, esxi, resource_pool, cluster_name, guest, module.fail_json( msg="Error on %s definition. type needs to be" " specified." % disk) + if disk_num == 7: + disk_num = disk_num + 1 + disk_key = disk_key + 1 + elif disk_num > 15: + bus_num = bus_num + 1 + disk_ctrl = disk_ctrl + 1 + disk_ctrl_key = add_scsi_controller( + module, vsphere_client, config, devices, type=vm_hardware['scsi'], bus_num=bus_num, disk_ctrl_key=disk_ctrl) + disk_num = 0 + disk_key = 0 # Add the disk to the VM spec. add_disk( module, vsphere_client, config_target, config,