From 483c25a6095e8ac7c8cf8d0955ed84859de4a6c3 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 5 Nov 2015 15:41:17 -0500 Subject: [PATCH] Revert "switched host patterns to use sets, simplified logic which now uses buitins" need this to be lists, for order and other considerations This reverts commit 8e2f0b3f2c9b4ce31ea93701fe9a878d00d92cb3. --- lib/ansible/inventory/__init__.py | 9 +++++---- lib/ansible/vars/hostvars.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index a984a99ec1..a967553385 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -252,7 +252,7 @@ class Inventory(object): """ patterns = Inventory.order_patterns(patterns) - hosts = set() + hosts = [] for p in patterns: # avoid resolving a pattern that is a plain host @@ -261,11 +261,12 @@ class Inventory(object): else: that = self._match_one_pattern(p) if p.startswith("!"): - hosts = hosts.difference_update(that) + hosts = [ h for h in hosts if h not in that ] elif p.startswith("&"): - hosts = hosts.intersection_update(that) + hosts = [ h for h in hosts if h in that ] else: - hosts.update(that) + to_append = [ h for h in that if h.name not in [ y.name for y in hosts ] ] + hosts.extend(to_append) return hosts def _match_one_pattern(self, pattern): diff --git a/lib/ansible/vars/hostvars.py b/lib/ansible/vars/hostvars.py index aeecc326ee..9f83342be3 100644 --- a/lib/ansible/vars/hostvars.py +++ b/lib/ansible/vars/hostvars.py @@ -56,7 +56,7 @@ class HostVars(collections.Mapping): new_host.set_variable("ansible_python_interpreter", sys.executable) new_host.set_variable("ansible_connection", "local") new_host.address = '127.0.0.1' - hosts.add(new_host) + hosts.append(new_host) for host in hosts: self._lookup[host.name] = host