mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
VMware: vmware_host_config_manager: avoid failure if no change (#55115)
If nothing was changed, the module was raising the following error because the `message` variable was not defined:
This commit is contained in:
parent
f96c569f9d
commit
754dfc54c8
1 changed files with 3 additions and 4 deletions
|
@ -125,7 +125,7 @@ class VmwareConfigManager(PyVmomi):
|
||||||
|
|
||||||
def set_host_configuration_facts(self):
|
def set_host_configuration_facts(self):
|
||||||
changed_list = []
|
changed_list = []
|
||||||
changed = False
|
message = ''
|
||||||
for host in self.hosts:
|
for host in self.hosts:
|
||||||
option_manager = host.configManager.advancedOption
|
option_manager = host.configManager.advancedOption
|
||||||
host_facts = {}
|
host_facts = {}
|
||||||
|
@ -161,11 +161,10 @@ class VmwareConfigManager(PyVmomi):
|
||||||
|
|
||||||
if option_value != host_facts[option_key]['value']:
|
if option_value != host_facts[option_key]['value']:
|
||||||
change_option_list.append(vim.option.OptionValue(key=option_key, value=option_value))
|
change_option_list.append(vim.option.OptionValue(key=option_key, value=option_value))
|
||||||
changed = True
|
|
||||||
changed_list.append(option_key)
|
changed_list.append(option_key)
|
||||||
else: # Don't silently drop unknown options. This prevents typos from falling through the cracks.
|
else: # Don't silently drop unknown options. This prevents typos from falling through the cracks.
|
||||||
self.module.fail_json(msg="Unsupported option %s" % option_key)
|
self.module.fail_json(msg="Unsupported option %s" % option_key)
|
||||||
if changed:
|
if changed_list:
|
||||||
if self.module.check_mode:
|
if self.module.check_mode:
|
||||||
changed_suffix = ' would be changed.'
|
changed_suffix = ' would be changed.'
|
||||||
else:
|
else:
|
||||||
|
@ -189,7 +188,7 @@ class VmwareConfigManager(PyVmomi):
|
||||||
else:
|
else:
|
||||||
message = 'All settings are already configured.'
|
message = 'All settings are already configured.'
|
||||||
|
|
||||||
self.module.exit_json(changed=changed, msg=message)
|
self.module.exit_json(changed=bool(changed_list), msg=message)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
Loading…
Reference in a new issue