mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix for the directory inventory source where depth information on the group was being discarded
due to initial copy. New model will reuse the first object and copy attributes on the second.
This commit is contained in:
parent
be33bcf16f
commit
c52abd40b0
1 changed files with 13 additions and 6 deletions
|
@ -62,15 +62,22 @@ class InventoryDirectory(object):
|
|||
# This takes a lot of code because we can't directly use any of the objects, as they have to blend
|
||||
for name, group in parser.groups.iteritems():
|
||||
if name not in self.groups:
|
||||
self.groups[name] = Group(name)
|
||||
for k, v in group.get_variables().iteritems():
|
||||
self.groups[name].set_variable(k, v)
|
||||
self.groups[name] = group
|
||||
else:
|
||||
# group is already there, copy variables
|
||||
# note: depth numbers on duplicates may be bogus
|
||||
for k, v in group.get_variables().iteritems():
|
||||
self.groups[name].set_variable(k, v)
|
||||
for host in group.get_hosts():
|
||||
if host.name not in self.hosts:
|
||||
self.hosts[host.name] = Host(host.name)
|
||||
for k, v in host.vars.iteritems():
|
||||
self.hosts[host.name].set_variable(k, v)
|
||||
self.hosts[host.name] = host
|
||||
else:
|
||||
# host is already there, copy variables
|
||||
# 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])
|
||||
|
||||
# This needs to be a second loop to ensure all the parent groups exist
|
||||
for name, group in parser.groups.iteritems():
|
||||
for ancestor in group.get_ancestors():
|
||||
|
|
Loading…
Reference in a new issue