diff --git a/lib/ansible/inventory/data.py b/lib/ansible/inventory/data.py index 25dff3d0620..edb3f13cd0d 100644 --- a/lib/ansible/inventory/data.py +++ b/lib/ansible/inventory/data.py @@ -238,6 +238,7 @@ class InventoryData(object): # match on host name/inventory_hostname is unique id if hostobj.name == host.name: del self.hosts[hostobj] + break for group in self.groups: g = self.groups[group] diff --git a/lib/ansible/inventory/group.py b/lib/ansible/inventory/group.py index 8c9d4a6465a..898f852bf4e 100644 --- a/lib/ansible/inventory/group.py +++ b/lib/ansible/inventory/group.py @@ -243,6 +243,7 @@ class Group: for hostobj in self.hosts: if hostobj.name == host.name: self.hosts.remove(hostobj) + break self._hosts.remove(host.name) host.remove_group(self) self.clear_hosts_cache()