From 4fc8e7c7e75ae079fa383150fd5c34e085187612 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 8 Dec 2023 11:13:29 -0500 Subject: [PATCH] there can only be one --- lib/ansible/inventory/data.py | 1 + lib/ansible/inventory/group.py | 1 + 2 files changed, 2 insertions(+) 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()