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

ensure all hosts in all

fixes #20252
This commit is contained in:
Brian Coca 2017-03-08 11:57:31 -05:00 committed by Brian Coca
parent ced73389de
commit 385f1d82dc

View file

@ -140,7 +140,6 @@ class Inventory(object):
display.warning("A duplicate localhost-like entry was found (%s). First found localhost was %s" % (h, self.localhost.name)) display.warning("A duplicate localhost-like entry was found (%s). First found localhost was %s" % (h, self.localhost.name))
display.vvvv("Set default localhost to %s" % h) display.vvvv("Set default localhost to %s" % h)
self.localhost = new_host self.localhost = new_host
all.add_host(new_host)
elif self._loader.path_exists(host_list): elif self._loader.path_exists(host_list):
# TODO: switch this to a plugin loader and a 'condition' per plugin on which it should be tried, restoring 'inventory pllugins' # TODO: switch this to a plugin loader and a 'condition' per plugin on which it should be tried, restoring 'inventory pllugins'
if self.is_directory(host_list): if self.is_directory(host_list):
@ -170,8 +169,13 @@ class Inventory(object):
host.vars = combine_vars(host.vars, self.get_host_variables(host.name)) host.vars = combine_vars(host.vars, self.get_host_variables(host.name))
self.get_host_vars(host) self.get_host_vars(host)
# clear ungrouped of any incorrectly stored by parser
mygroups = host.get_groups() mygroups = host.get_groups()
# ensure hosts are always in 'all'
if all not in mygroups:
all.add_host(host)
# clear ungrouped of any incorrectly stored by parser
if len(mygroups) > 2 and ungrouped in mygroups: if len(mygroups) > 2 and ungrouped in mygroups:
host.remove_group(ungrouped) host.remove_group(ungrouped)