mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
inventory directory parser: add host to group only once
This commit is contained in:
parent
8b215149d4
commit
36f55d3549
1 changed files with 4 additions and 1 deletions
|
@ -79,6 +79,9 @@ class InventoryDirectory(object):
|
||||||
# note: depth numbers on duplicates may be bogus
|
# note: depth numbers on duplicates may be bogus
|
||||||
for k, v in host.vars.iteritems():
|
for k, v in host.vars.iteritems():
|
||||||
self.hosts[host.name].set_variable(k, v)
|
self.hosts[host.name].set_variable(k, v)
|
||||||
|
# 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])
|
self.groups[name].add_host(self.hosts[host.name])
|
||||||
|
|
||||||
# This needs to be a second loop to ensure all the parent groups exist
|
# This needs to be a second loop to ensure all the parent groups exist
|
||||||
|
|
Loading…
Reference in a new issue