1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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 8e2f0b3f2c.
This commit is contained in:
Brian Coca 2015-11-05 15:41:17 -05:00
parent 88ba46aee0
commit 483c25a609
2 changed files with 6 additions and 5 deletions

View file

@ -252,7 +252,7 @@ class Inventory(object):
""" """
patterns = Inventory.order_patterns(patterns) patterns = Inventory.order_patterns(patterns)
hosts = set() hosts = []
for p in patterns: for p in patterns:
# avoid resolving a pattern that is a plain host # avoid resolving a pattern that is a plain host
@ -261,11 +261,12 @@ class Inventory(object):
else: else:
that = self._match_one_pattern(p) that = self._match_one_pattern(p)
if p.startswith("!"): if p.startswith("!"):
hosts = hosts.difference_update(that) hosts = [ h for h in hosts if h not in that ]
elif p.startswith("&"): elif p.startswith("&"):
hosts = hosts.intersection_update(that) hosts = [ h for h in hosts if h in that ]
else: 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 return hosts
def _match_one_pattern(self, pattern): def _match_one_pattern(self, pattern):

View file

@ -56,7 +56,7 @@ class HostVars(collections.Mapping):
new_host.set_variable("ansible_python_interpreter", sys.executable) new_host.set_variable("ansible_python_interpreter", sys.executable)
new_host.set_variable("ansible_connection", "local") new_host.set_variable("ansible_connection", "local")
new_host.address = '127.0.0.1' new_host.address = '127.0.0.1'
hosts.add(new_host) hosts.append(new_host)
for host in hosts: for host in hosts:
self._lookup[host.name] = host self._lookup[host.name] = host