mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-18 23:01:14 +00:00
corrected host/group match in inventory_hostnames
now the lookup works when using ! and & operators fixes #13997
This commit is contained in:
@@ -26,10 +26,15 @@ class LookupModule(LookupBase):
|
||||
|
||||
def get_hosts(self, variables, pattern):
|
||||
hosts = []
|
||||
if pattern in variables['groups']:
|
||||
hosts = variables['groups'][pattern]
|
||||
elif pattern in variables['groups']['all']:
|
||||
hosts = [pattern]
|
||||
if pattern[0] in ('!','&'):
|
||||
obj = pattern[1:]
|
||||
else:
|
||||
obj = pattern
|
||||
|
||||
if obj in variables['groups']:
|
||||
hosts = variables['groups'][obj]
|
||||
elif obj in variables['groups']['all']:
|
||||
hosts = [obj]
|
||||
return hosts
|
||||
|
||||
def run(self, terms, variables=None, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user