From cd0812a187fc8d94a4c5159a4eabe1b48aed47a0 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Mon, 25 Jan 2016 17:37:39 -0500 Subject: [PATCH] adhoc now respects limit when listing hosts also removed cruft about localhost as if used it is specified inline fixes #13848 --- lib/ansible/cli/adhoc.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index 250241a848f..97df8fcdbf0 100644 --- a/lib/ansible/cli/adhoc.py +++ b/lib/ansible/cli/adhoc.py @@ -124,17 +124,13 @@ class AdHocCLI(CLI): inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=self.options.inventory) variable_manager.set_inventory(inventory) - hosts = inventory.list_hosts(pattern) - no_hosts = False - if len(hosts) == 0: - display.warning("provided hosts list is empty, only localhost is available") - no_hosts = True if self.options.subset: inventory.subset(self.options.subset) - if len(inventory.list_hosts(pattern)) == 0 and not no_hosts: - # Invalid limit - raise AnsibleError("Specified --limit does not match any hosts") + + hosts = inventory.list_hosts(pattern) + if len(hosts) == 0: + raise AnsibleError("Specified hosts options do not match any hosts") if self.options.listhosts: display.display(' hosts (%d):' % len(hosts))