From bda0687d28a97e9f98c799f00dc344c7d35f23a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A9ri=20Le=20Bouder?= Date: Tue, 9 Apr 2019 01:04:47 -0400 Subject: [PATCH] vmware_host: ensure idempotency with state=absent (#54608) If a host is already missing, `self.host_update` is `None`. With this change,`state_exit_unchanged()` won't try anymore to access `self.host_update.runtime`. --- lib/ansible/modules/cloud/vmware/vmware_host.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_host.py b/lib/ansible/modules/cloud/vmware/vmware_host.py index 75993f5ee87..c6a5b6d40f5 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host.py @@ -341,7 +341,9 @@ class VMwareHost(PyVmomi): def state_exit_unchanged(self): """Exit with status message""" - if self.reconnect_disconnected and self.host_update.runtime.connectionState == 'disconnected': + if not self.host_update: + result = "Host already disconnected" + elif self.reconnect_disconnected and self.host_update.runtime.connectionState == 'disconnected': self.state_reconnect_host() else: if self.folder_name: