summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2022-12-06 17:10:31 -0500
committerGitHub <noreply@github.com>2022-12-06 14:10:31 -0800
commitd40213c32c21b96823a21a2328074f482b6a2234 (patch)
tree3488de2ec86595d9ac6ed85798c1a029e755d776 /lib
parentfc2670772a44fd51dcfa81034d2ae0e9ecabecd8 (diff)
downloadansible-d40213c32c21b96823a21a2328074f482b6a2234.tar.gz
Removed sorting to preserve original order (#74839) (#79517)
updated tests to reflect new order (cherry picked from commit 5b51b560d0328e35dad5d4c77688f7577081c0ed)
Diffstat (limited to 'lib')
-rwxr-xr-xlib/ansible/cli/inventory.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/ansible/cli/inventory.py b/lib/ansible/cli/inventory.py
index 0e86080121..e8ed75e463 100755
--- a/lib/ansible/cli/inventory.py
+++ b/lib/ansible/cli/inventory.py
@@ -13,7 +13,6 @@ from ansible.cli import CLI
import sys
import argparse
-from operator import attrgetter
from ansible import constants as C
from ansible import context
@@ -273,11 +272,11 @@ class InventoryCLI(CLI):
result = [self._graph_name('@%s:' % group.name, depth)]
depth = depth + 1
- for kid in sorted(group.child_groups, key=attrgetter('name')):
+ for kid in group.child_groups:
result.extend(self._graph_group(kid, depth))
if group.name != 'all':
- for host in sorted(group.hosts, key=attrgetter('name')):
+ for host in group.hosts:
result.append(self._graph_name(host.name, depth))
if context.CLIARGS['show_vars']:
result.extend(self._show_vars(self._get_host_variables(host), depth + 1))
@@ -303,9 +302,9 @@ class InventoryCLI(CLI):
results = {}
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]['hosts'] = [h.name for h in group.hosts]
results[group.name]['children'] = []
- for subgroup in sorted(group.child_groups, key=attrgetter('name')):
+ for subgroup in group.child_groups:
results[group.name]['children'].append(subgroup.name)
if subgroup.name not in seen:
results.update(format_group(subgroup))
@@ -343,14 +342,14 @@ class InventoryCLI(CLI):
# subgroups
results[group.name]['children'] = {}
- for subgroup in sorted(group.child_groups, key=attrgetter('name')):
+ for subgroup in group.child_groups:
if subgroup.name != 'all':
results[group.name]['children'].update(format_group(subgroup))
# hosts for group
results[group.name]['hosts'] = {}
if group.name != 'all':
- for h in sorted(group.hosts, key=attrgetter('name')):
+ for h in group.hosts:
myvars = {}
if h.name not in seen: # avoid defining host vars more than once
seen.append(h.name)
@@ -377,7 +376,7 @@ class InventoryCLI(CLI):
results[group.name] = {}
results[group.name]['children'] = []
- for subgroup in sorted(group.child_groups, key=attrgetter('name')):
+ for subgroup in group.child_groups:
if subgroup.name == 'ungrouped' and not has_ungrouped:
continue
if group.name != 'all':
@@ -385,7 +384,7 @@ class InventoryCLI(CLI):
results.update(format_group(subgroup))
if group.name != 'all':
- for host in sorted(group.hosts, key=attrgetter('name')):
+ for host in group.hosts:
if host.name not in seen:
seen.add(host.name)
host_vars = self._get_host_variables(host=host)