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

deal with other 'ungrouped' corner cases

This commit is contained in:
Brian Coca 2017-03-09 20:11:37 -05:00
parent 7b167e7947
commit 2d9bf88897

View file

@ -176,9 +176,16 @@ class Inventory(object):
if all not in mygroups: if all not in mygroups:
all.add_host(host) all.add_host(host)
if ungrouped in mygroups:
# clear ungrouped of any incorrectly stored by parser # clear ungrouped of any incorrectly stored by parser
if len(mygroups) > 2 and ungrouped in mygroups: if set(mygroups).difference(set([all, ungrouped])):
host.remove_group(ungrouped) host.remove_group(ungrouped)
else:
# add ungrouped hosts to ungrouped
length = len(mygroups)
if length == 0 or (length == 1 and all in mygroups):
ungrouped.add_host(host)
def _match(self, str, pattern_str): def _match(self, str, pattern_str):
try: try: