|
|
@ -46,6 +46,7 @@ class InventoryScript(object):
|
|
|
|
self.host_vars_from_top = None
|
|
|
|
self.host_vars_from_top = None
|
|
|
|
self.groups = self._parse(stderr)
|
|
|
|
self.groups = self._parse(stderr)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _parse(self, err):
|
|
|
|
def _parse(self, err):
|
|
|
|
|
|
|
|
|
|
|
|
all_hosts = {}
|
|
|
|
all_hosts = {}
|
|
|
@ -60,7 +61,7 @@ class InventoryScript(object):
|
|
|
|
raise errors.AnsibleError("failed to parse executable inventory script results: %s" % self.raw)
|
|
|
|
raise errors.AnsibleError("failed to parse executable inventory script results: %s" % self.raw)
|
|
|
|
|
|
|
|
|
|
|
|
for (group_name, data) in self.raw.items():
|
|
|
|
for (group_name, data) in self.raw.items():
|
|
|
|
|
|
|
|
|
|
|
|
# in Ansible 1.3 and later, a "_meta" subelement may contain
|
|
|
|
# in Ansible 1.3 and later, a "_meta" subelement may contain
|
|
|
|
# a variable "hostvars" which contains a hash for each host
|
|
|
|
# a variable "hostvars" which contains a hash for each host
|
|
|
|
# if this "hostvars" exists at all then do not call --host for each
|
|
|
|
# if this "hostvars" exists at all then do not call --host for each
|
|
|
@ -97,8 +98,6 @@ class InventoryScript(object):
|
|
|
|
all.set_variable(k, v)
|
|
|
|
all.set_variable(k, v)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
group.set_variable(k, v)
|
|
|
|
group.set_variable(k, v)
|
|
|
|
if group.name != all.name:
|
|
|
|
|
|
|
|
all.add_child_group(group)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Separate loop to ensure all groups are defined
|
|
|
|
# Separate loop to ensure all groups are defined
|
|
|
|
for (group_name, data) in self.raw.items():
|
|
|
|
for (group_name, data) in self.raw.items():
|
|
|
@ -108,6 +107,11 @@ class InventoryScript(object):
|
|
|
|
for child_name in data['children']:
|
|
|
|
for child_name in data['children']:
|
|
|
|
if child_name in groups:
|
|
|
|
if child_name in groups:
|
|
|
|
groups[group_name].add_child_group(groups[child_name])
|
|
|
|
groups[group_name].add_child_group(groups[child_name])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for group in groups.values():
|
|
|
|
|
|
|
|
if group.depth == 0 and group.name != 'all':
|
|
|
|
|
|
|
|
all.add_child_group(group)
|
|
|
|
|
|
|
|
|
|
|
|
return groups
|
|
|
|
return groups
|
|
|
|
|
|
|
|
|
|
|
|
def get_host_variables(self, host):
|
|
|
|
def get_host_variables(self, host):
|
|
|
|