Enable negated patterns

A host pattern of the form '!foo' by itself does not work, but
'all:!foo' does. If the first pattern is a negation, this commit
automatically prepends 'all'.

Signed-off-by: martin f. krafft <madduck@madduck.net>
pull/3275/head
martin f. krafft 12 years ago
parent 995ef374db
commit fd02443d42

@ -136,6 +136,11 @@ class Inventory(object):
finds hosts that match a list of patterns. Handles negative finds hosts that match a list of patterns. Handles negative
matches as well as intersection matches. matches as well as intersection matches.
""" """
try:
if patterns[0].startswith("!"):
patterns.insert(0, "all")
except IndexError:
pass
hosts = set() hosts = set()
for p in patterns: for p in patterns:

Loading…
Cancel
Save