From c5b303fa5267c3ff8c8834a87b55d2a01901e9e0 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 6 Nov 2018 07:19:58 -0600 Subject: [PATCH] Test host in inventory by name in remove_host (#45639) The host argument is a Host object, and is used as such by group.remove_host. However, self.hosts is a dictionary of host name to Host object. Thus, the existing code is checking to see if the Host object is one of the keys. Use host.name to interact with the keys of the dictionary. --- lib/ansible/inventory/data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/data.py b/lib/ansible/inventory/data.py index 7eb626d1e32..640a059f751 100644 --- a/lib/ansible/inventory/data.py +++ b/lib/ansible/inventory/data.py @@ -224,8 +224,8 @@ class InventoryData(object): def remove_host(self, host): - if host in self.hosts: - del self.hosts[host] + if host.name in self.hosts: + del self.hosts[host.name] for group in self.groups: g = self.groups[group]