Revert pull request #1684
This commit is contained in:
parent
7c2c6fee3a
commit
63c1b2e17e
1 changed files with 2 additions and 10 deletions
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import ansible.constants as C
|
import ansible.constants as C
|
||||||
|
@ -165,7 +164,7 @@ class Inventory(object):
|
||||||
a tuple of (start, stop) or None
|
a tuple of (start, stop) or None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not "[" in pattern or '~' in pattern:
|
if not "[" in pattern:
|
||||||
return (pattern, None)
|
return (pattern, None)
|
||||||
(first, rest) = pattern.split("[")
|
(first, rest) = pattern.split("[")
|
||||||
rest = rest.replace("]","")
|
rest = rest.replace("]","")
|
||||||
|
@ -202,18 +201,11 @@ class Inventory(object):
|
||||||
hosts = {}
|
hosts = {}
|
||||||
# ignore any negative checks here, this is handled elsewhere
|
# ignore any negative checks here, this is handled elsewhere
|
||||||
pattern = pattern.replace("!","")
|
pattern = pattern.replace("!","")
|
||||||
is_re = False
|
|
||||||
if '~' in pattern:
|
|
||||||
is_re = True
|
|
||||||
hostregex = pattern.split('~', 1)[1]
|
|
||||||
|
|
||||||
groups = self.get_groups()
|
groups = self.get_groups()
|
||||||
for group in groups:
|
for group in groups:
|
||||||
for host in group.get_hosts():
|
for host in group.get_hosts():
|
||||||
if pattern == 'all' \
|
if pattern == 'all' or self._match(group.name, pattern) or self._match(host.name, pattern):
|
||||||
or self._match(group.name, pattern) \
|
|
||||||
or self._match(host.name, pattern) \
|
|
||||||
or (is_re and re.search(hostregex, host.name)):
|
|
||||||
hosts[host.name] = host
|
hosts[host.name] = host
|
||||||
return sorted(hosts.values(), key=lambda x: x.name)
|
return sorted(hosts.values(), key=lambda x: x.name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue