diff options
| author | Matt Martz <matt@sivel.net> | 2017-06-19 15:12:35 -0500 |
|---|---|---|
| committer | Brian Coca <bcoca@users.noreply.github.com> | 2017-06-19 17:38:43 -0400 |
| commit | b6ee9163e340cd47d8adffe331576b0b37f740a5 (patch) | |
| tree | 674899cff973a6dd425fd3787787e0d6879d88a2 | |
| parent | 9730d965179d3d4c34b136df24a813eb91ed8a61 (diff) | |
| download | ansible-b6ee9163e340cd47d8adffe331576b0b37f740a5.tar.gz | |
Ensure hosts aren't duplicated in groups
| -rw-r--r-- | lib/ansible/inventory/data.py | 2 | ||||
| -rw-r--r-- | lib/ansible/inventory/group.py | 3 |
2 files changed, 3 insertions, 2 deletions
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() |
