diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index 1d8d43b0d2a..ff5e512402d 100644 --- a/lib/ansible/cli/adhoc.py +++ b/lib/ansible/cli/adhoc.py @@ -119,7 +119,7 @@ class AdHocCLI(CLI): if self.options.subset: inventory.subset(self.options.subset) - if len(inventory.list_hosts()) == 0 and not no_hosts: + if len(inventory.list_hosts(pattern)) == 0 and not no_hosts: # Invalid limit raise AnsibleError("Specified --limit does not match any hosts")