Merge pull request #12431 from hslee16/devel

Stops using _groups_list to check for host when using 'add_host'
pull/12446/head
James Cammarata 9 years ago
commit 65bf14cbb0

@ -461,7 +461,10 @@ class Inventory(object):
return matching_host return matching_host
def get_group(self, groupname): def get_group(self, groupname):
if groupname in self.groups:
return self.groups[groupname] return self.groups[groupname]
else:
return None
def get_group_variables(self, groupname, update_cached=False, vault_password=None): def get_group_variables(self, groupname, update_cached=False, vault_password=None):
if groupname not in self._vars_per_group or update_cached: if groupname not in self._vars_per_group or update_cached:

@ -356,10 +356,10 @@ class StrategyBase:
new_group.add_host(new_host) new_group.add_host(new_host)
# add this host to the group cache # add this host to the group cache
if self._inventory._groups_list is not None: if self._inventory.groups is not None:
if group_name in self._inventory._groups_list: if group_name in self._inventory.groups:
if new_host.name not in self._inventory._groups_list[group_name]: if new_host not in self._inventory.get_group(group_name).hosts:
self._inventory._groups_list[group_name].append(new_host.name) self._inventory.get_group(group_name).hosts.append(new_host.name)
# clear pattern caching completely since it's unpredictable what # clear pattern caching completely since it's unpredictable what
# patterns may have referenced the group # patterns may have referenced the group

Loading…
Cancel
Save