Ensure hosts aren't duplicated in groups

pull/25829/merge
Matt Martz 7 years ago committed by Brian Coca
parent 9730d96517
commit b6ee9163e3

@ -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()

Loading…
Cancel
Save