mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
vmware_guest: Fix customvalues when VM doesn't exists (#20094)
This commit is contained in:
parent
3ceff2f9b3
commit
16a1585ffc
1 changed files with 3 additions and 3 deletions
|
@ -758,7 +758,6 @@ class PyVmomiHelper(object):
|
|||
return result
|
||||
|
||||
def gather_facts(self, vm):
|
||||
|
||||
""" Gather facts from vim.VirtualMachine object. """
|
||||
facts = {
|
||||
'module_hw': True,
|
||||
|
@ -978,7 +977,7 @@ class PyVmomiHelper(object):
|
|||
self.module.exit_json(msg="customvalues items required both 'key' and 'value fields.")
|
||||
|
||||
# If kv is not kv fetched from facts, change it
|
||||
if kv['key'] in facts['customvalues'] and facts['customvalues'][kv['key']] != kv['value']:
|
||||
if kv['key'] not in facts['customvalues'] or facts['customvalues'][kv['key']] != kv['value']:
|
||||
try:
|
||||
vm_obj.setCustomValue(key=kv['key'], value=kv['value'])
|
||||
self.change_detected = True
|
||||
|
@ -1340,7 +1339,6 @@ class PyVmomiHelper(object):
|
|||
self.configure_cpu_and_memory(vm_obj=vm_obj, vm_creation=True)
|
||||
self.configure_disks(vm_obj=vm_obj)
|
||||
self.configure_network(vm_obj=vm_obj)
|
||||
self.customize_customvalues(vm_obj=vm_obj)
|
||||
|
||||
if len(self.params['customization']) > 0:
|
||||
self.customize_vm(vm_obj=vm_obj)
|
||||
|
@ -1385,6 +1383,8 @@ class PyVmomiHelper(object):
|
|||
task = vm.ReconfigVM_Task(annotation_spec)
|
||||
self.wait_for_task(task)
|
||||
|
||||
self.customize_customvalues(vm_obj=vm)
|
||||
|
||||
if self.params['wait_for_ip_address'] or self.params['state'] in ['poweredon', 'restarted']:
|
||||
self.set_powerstate(vm, 'poweredon', force=False)
|
||||
|
||||
|
|
Loading…
Reference in a new issue