diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index a5780c1982..3e0f44859a 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -109,8 +109,8 @@ class Inventory(object): # exclude hosts mentioned in a negative pattern if len(negative_patterns): - exclude_hosts = self._get_hosts(negative_patterns) - hosts = [ h for h in hosts if h not in exclude_hosts ] + exclude_hosts = [ h.name for h in self._get_hosts(negative_patterns) ] + hosts = [ h for h in hosts if h.name not in exclude_hosts ] # exclude hosts not in a subset, if defined if self._subset: