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

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>
This commit is contained in:
martin f. krafft 2013-06-20 07:55:35 +02:00
parent 995ef374db
commit fd02443d42

View file

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