diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_config_manager.py b/lib/ansible/modules/cloud/vmware/vmware_host_config_manager.py index a426f88eb5..2e7e6ede4a 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_config_manager.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_config_manager.py @@ -125,7 +125,7 @@ class VmwareConfigManager(PyVmomi): def set_host_configuration_facts(self): changed_list = [] - changed = False + message = '' for host in self.hosts: option_manager = host.configManager.advancedOption host_facts = {} @@ -161,11 +161,10 @@ class VmwareConfigManager(PyVmomi): if option_value != host_facts[option_key]['value']: change_option_list.append(vim.option.OptionValue(key=option_key, value=option_value)) - changed = True changed_list.append(option_key) 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) - if changed: + if changed_list: if self.module.check_mode: changed_suffix = ' would be changed.' else: @@ -189,7 +188,7 @@ class VmwareConfigManager(PyVmomi): else: 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():