diff options
author | Sloane Hertel <shertel@redhat.com> | 2019-04-18 15:54:03 -0400 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2019-04-18 15:54:03 -0400 |
commit | afb5e02c19c5270c9452177ddd29a99fb6253578 (patch) | |
tree | 0c954b416cc364f6ff59f4f5be38baf2aa040926 /lib/ansible/inventory | |
parent | 0330ea616eee7183920be45a34737f0d72aaf184 (diff) | |
download | ansible-afb5e02c19c5270c9452177ddd29a99fb6253578.tar.gz |
preserve same order as inventory manager when using host lookup (#55331)
* preserve same order as inventory manager when using inventory_hostnames lookup
add a test
* move generic code
Diffstat (limited to 'lib/ansible/inventory')
-rw-r--r-- | lib/ansible/inventory/manager.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py index 10785aa793..cc43e4e468 100644 --- a/lib/ansible/inventory/manager.py +++ b/lib/ansible/inventory/manager.py @@ -36,6 +36,7 @@ from ansible.module_utils.six import string_types from ansible.module_utils._text import to_bytes, to_text from ansible.parsing.utils.addresses import parse_address from ansible.plugins.loader import inventory_loader +from ansible.utils.helpers import deduplicate_list from ansible.utils.path import unfrackpath from ansible.utils.display import Display @@ -369,8 +370,7 @@ class InventoryManager(object): # exclude hosts mentioned in any restriction (ex: failed hosts) hosts = [h for h in hosts if h.name in self._restriction] - seen = set() - self._hosts_patterns_cache[pattern_hash] = [x for x in hosts if x not in seen and not seen.add(x)] + self._hosts_patterns_cache[pattern_hash] = deduplicate_list(hosts) # sort hosts list if needed (should only happen when called from strategy) if order in ['sorted', 'reverse_sorted']: |