summaryrefslogtreecommitdiff
path: root/lib/ansible/inventory/dir.py
diff options
context:
space:
mode:
authorSerge van Ginderachter <serge@vanginderachter.be>2014-03-05 16:26:26 +0100
committerSerge van Ginderachter <serge@vanginderachter.be>2014-03-25 12:45:00 +0100
commit36f55d354932d5dd29f8ecf17a6d1338f11b13d7 (patch)
tree25bcdc887813b8881cd41a1ce53f6eac8a48625a /lib/ansible/inventory/dir.py
parent8b215149d4694ab2644df4f231790c3382462d97 (diff)
downloadansible-36f55d354932d5dd29f8ecf17a6d1338f11b13d7.tar.gz
inventory directory parser: add host to group only once
Diffstat (limited to 'lib/ansible/inventory/dir.py')
-rw-r--r--lib/ansible/inventory/dir.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/ansible/inventory/dir.py b/lib/ansible/inventory/dir.py
index 37cc539044..39f45f0920 100644
--- a/lib/ansible/inventory/dir.py
+++ b/lib/ansible/inventory/dir.py
@@ -79,7 +79,10 @@ class InventoryDirectory(object):
# note: depth numbers on duplicates may be bogus
for k, v in host.vars.iteritems():
self.hosts[host.name].set_variable(k, v)
- self.groups[name].add_host(self.hosts[host.name])
+ # host can already exist from other source (same name,
+ # different object):
+ if host.name not in [h.name for h in self.groups[name].hosts]:
+ self.groups[name].add_host(self.hosts[host.name])
# This needs to be a second loop to ensure all the parent groups exist
for name, group in parser.groups.iteritems():