diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 3099bd8d1b6..6e83064f83f 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -114,11 +114,11 @@ class Inventory(object): positive_subsetp = [ p for p in self._subset if not p.startswith("!") ] negative_subsetp = [ p for p in self._subset if p.startswith("!") ] if len(positive_subsetp): - positive_subset = self._get_hosts(positive_subsetp) - hosts = [ h for h in hosts if (h in positive_subset) ] + positive_subset = [ h.name for h in self._get_hosts(positive_subsetp) ] + hosts = [ h for h in hosts if (h.name in positive_subset) ] if len(negative_subsetp): - negative_subset = self._get_hosts(negative_subsetp) - hosts = [ h for h in hosts if (h not in negative_subset)] + negative_subset = [ h.name for h in self._get_hosts(negative_subsetp) ] + hosts = [ h for h in hosts if (h.name not in negative_subset)] # exclude hosts mentioned in any restriction (ex: failed hosts) if self._restriction is not None: