mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Ensure hosts aren't duplicated in groups
This commit is contained in:
parent
9730d96517
commit
b6ee9163e3
2 changed files with 3 additions and 2 deletions
|
@ -231,7 +231,7 @@ class InventoryData(object):
|
||||||
else:
|
else:
|
||||||
h = self.hosts[host]
|
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)
|
g.add_host(h)
|
||||||
self._groups_dict_cache = {}
|
self._groups_dict_cache = {}
|
||||||
display.debug("Added host %s to group %s" % (host, group))
|
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)
|
raise AnsibleError("The group named '%s' has a recursive dependency loop." % self.name)
|
||||||
|
|
||||||
def add_host(self, host):
|
def add_host(self, host):
|
||||||
|
if host in self.hosts:
|
||||||
|
return
|
||||||
self.hosts.append(host)
|
self.hosts.append(host)
|
||||||
host.add_group(self)
|
host.add_group(self)
|
||||||
self.clear_hosts_cache()
|
self.clear_hosts_cache()
|
||||||
|
|
Loading…
Reference in a new issue