From 34d7f9e3db3dbbeabd58261e8b750ba66f99762b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 30 Oct 2017 12:59:43 -0400 Subject: [PATCH] remove misleading group vars as they are flat (#32276) * remove misleading group vars as they are flat * fixed vars display (cherry picked from commit 75a6f9dbc27c883e035349ac8efb342d51cb9d80) --- CHANGELOG.md | 2 ++ lib/ansible/cli/inventory.py | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96624981964..9cede27ce04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,8 @@ Ansible Changes By Release (https://github.com/ansible/ansible/pull/32342) * Ensure there is always a basdir so we always pickup group/host_vars https://github.com/ansible/ansible/pull/32269 +* Fix vars placement in ansible-inventory + https://github.com/ansible/ansible/pull/32276 diff --git a/lib/ansible/cli/inventory.py b/lib/ansible/cli/inventory.py index f0dba1171aa..6a4025cf3b7 100644 --- a/lib/ansible/cli/inventory.py +++ b/lib/ansible/cli/inventory.py @@ -206,7 +206,7 @@ class InventoryCLI(CLI): self._remove_internal(dump) if self.options.show_vars: for (name, val) in sorted(dump.items()): - result.append(self._graph_name('{%s = %s}' % (name, val), depth + 1)) + result.append(self._graph_name('{%s = %s}' % (name, val), depth)) return result def _graph_name(self, name, depth=0): @@ -224,7 +224,7 @@ class InventoryCLI(CLI): if group.name != 'all': for host in sorted(group.hosts, key=attrgetter('name')): result.append(self._graph_name(host.name, depth)) - result.extend(self._show_vars(host.get_vars(), depth)) + result.extend(self._show_vars(host.get_vars(), depth + 1)) result.extend(self._show_vars(group.get_vars(), depth)) @@ -245,7 +245,6 @@ class InventoryCLI(CLI): results[group.name] = {} if group.name != 'all': results[group.name]['hosts'] = [h.name for h in sorted(group.hosts, key=attrgetter('name'))] - results[group.name]['vars'] = group.get_vars() results[group.name]['children'] = [] for subgroup in sorted(group.child_groups, key=attrgetter('name')): results[group.name]['children'].append(subgroup.name) @@ -274,7 +273,6 @@ class InventoryCLI(CLI): # initialize group + vars results[group.name] = {} - results[group.name]['vars'] = group.get_vars() # subgroups results[group.name]['children'] = {}