mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00:00
Ensure hosts aren't duplicated in groups
This commit is contained in:
@@ -231,7 +231,7 @@ class InventoryData(object):
|
||||
else:
|
||||
h = self.hosts[host]
|
||||
|
||||
if g and host not in g.get_hosts():
|
||||
if g and h not in g.get_hosts():
|
||||
g.add_host(h)
|
||||
self._groups_dict_cache = {}
|
||||
display.debug("Added host %s to group %s" % (host, group))
|
||||
|
||||
@@ -112,7 +112,8 @@ class Group:
|
||||
raise AnsibleError("The group named '%s' has a recursive dependency loop." % self.name)
|
||||
|
||||
def add_host(self, host):
|
||||
|
||||
if host in self.hosts:
|
||||
return
|
||||
self.hosts.append(host)
|
||||
host.add_group(self)
|
||||
self.clear_hosts_cache()
|
||||
|
||||
Reference in New Issue
Block a user