summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cammarata <jimi@sngx.net>2015-12-03 15:25:54 -0500
committerJames Cammarata <jimi@sngx.net>2015-12-03 15:27:10 -0500
commit6aa1b6d9b1cbbac869691f742fa2dc3de8516126 (patch)
tree4c287838e553a1f9ede362af7e56aad8cac7b767
parent013ace9ab243cd6c286e34913ba87017f5024fc1 (diff)
downloadansible-6aa1b6d9b1cbbac869691f742fa2dc3de8516126.tar.gz
Properly compare object references for Hosts when adding new ones
Fixes #13397
-rw-r--r--lib/ansible/inventory/dir.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/ansible/inventory/dir.py b/lib/ansible/inventory/dir.py
index 7ae9611ddf..e4f7ee80f9 100644
--- a/lib/ansible/inventory/dir.py
+++ b/lib/ansible/inventory/dir.py
@@ -192,6 +192,8 @@ class InventoryDirectory(object):
if group.name not in self.groups:
# it's brand new, add him!
self.groups[group.name] = group
+ # the Group class does not (yet) implement __eq__/__ne__,
+ # so unlike Host we do a regular comparison here
if self.groups[group.name] != group:
# different object, merge
self._merge_groups(self.groups[group.name], group)
@@ -200,7 +202,10 @@ class InventoryDirectory(object):
if host.name not in self.hosts:
# Papa's got a brand new host
self.hosts[host.name] = host
- if self.hosts[host.name] != host:
+ # because the __eq__/__ne__ methods in Host() compare the
+ # name fields rather than references, we use id() here to
+ # do the object comparison for merges
+ if id(self.hosts[host.name]) != id(host):
# different object, merge
self._merge_hosts(self.hosts[host.name], host)