Clean up some bugs related to --limit on adhoc commands
This commit is contained in:
parent
621575681a
commit
babf47decb
1 changed files with 6 additions and 5 deletions
|
@ -18,7 +18,7 @@
|
|||
########################################################
|
||||
from ansible import constants as C
|
||||
from ansible.cli import CLI
|
||||
from ansible.errors import AnsibleOptionsError
|
||||
from ansible.errors import AnsibleError, AnsibleOptionsError
|
||||
from ansible.executor.task_queue_manager import TaskQueueManager
|
||||
from ansible.inventory import Inventory
|
||||
from ansible.parsing import DataLoader
|
||||
|
@ -117,10 +117,11 @@ class AdHocCLI(CLI):
|
|||
self.display.warning("provided hosts list is empty, only localhost is available")
|
||||
no_hosts = True
|
||||
|
||||
inventory.subset(self.options.subset)
|
||||
if len(inventory.list_hosts()) == 0 and not no_hosts:
|
||||
# Invalid limit
|
||||
raise AnsibleError("Specified --limit does not match any hosts")
|
||||
if self.options.subset:
|
||||
inventory.subset(self.options.subset)
|
||||
if len(inventory.list_hosts()) == 0 and not no_hosts:
|
||||
# Invalid limit
|
||||
raise AnsibleError("Specified --limit does not match any hosts")
|
||||
|
||||
if self.options.listhosts:
|
||||
self.display.display(' hosts (%d):' % len(hosts))
|
||||
|
|
Loading…
Reference in a new issue