diff --git a/lib/ansible/inventory/data.py b/lib/ansible/inventory/data.py index dba7523bc4..43a044e4e8 100644 --- a/lib/ansible/inventory/data.py +++ b/lib/ansible/inventory/data.py @@ -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)) diff --git a/lib/ansible/inventory/group.py b/lib/ansible/inventory/group.py index 3469b360f7..dd90c97ea6 100644 --- a/lib/ansible/inventory/group.py +++ b/lib/ansible/inventory/group.py @@ -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()