def run(self, terms, variables=None, **kwargs): host_list = [] for term in terms: patterns = Inventory.order_patterns(Inventory.split_host_pattern(term)) for p in patterns: that = self.get_hosts(variables, p) if p.startswith("!"): host_list = [ h for h in host_list if h not in that] elif p.startswith("&"): host_list = [ h for h in host_list if h in that ] else: host_list.extend(that) # return unique list return list(set(host_list))
def run(self, terms, variables=None, **kwargs): host_list = [] patterns = Inventory.order_patterns( Inventory.split_host_pattern(terms[0])) for pattern in patterns: hosts = self.get_hosts(pattern, variables) if pattern.startswith("!"): host_list = [host for host in host_list if host not in hosts] elif pattern.startswith("&"): host_list = [host for host in host_list if host in hosts] else: host_list.extend(hosts) return [ self.get_vars(host, terms[1:], variables) for host in list(set(host_list)) ]