vmware_guest: Don't force onto specific host (#22777)

Unless we provided a specific esxi_hostname, don't force new VMs onto the first host in the cluster.
This commit is contained in:
Dag Wieers 2017-05-05 11:27:04 +02:00 committed by ansibot
parent a07d42e16d
commit 58c1a9dd94

View file

@ -1090,6 +1090,8 @@ class PyVmomiHelper(object):
if self.should_deploy_from_template():
# create the relocation spec
relospec = vim.vm.RelocateSpec()
# Only provide specific host when using ESXi host directly
if self.params['esxi_hostname']:
relospec.host = hostsystem
relospec.datastore = datastore
relospec.pool = resource_pool
@ -1113,7 +1115,8 @@ class PyVmomiHelper(object):
self.change_detected = True
self.wait_for_task(task)
except TypeError:
self.module.fail_json(msg="TypeError was returned, please ensure to give correct inputs.")
e = get_exception()
self.module.fail_json(msg="TypeError was returned, please ensure to give correct inputs. %s" % e)
if task.info.state == 'error':
# https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2021361