adhoc now respects limit when listing hosts
also removed cruft about localhost as if used it is specified inline fixes #13848
This commit is contained in:
parent
864c67cec5
commit
cd0812a187
1 changed files with 4 additions and 8 deletions
|
@ -124,17 +124,13 @@ class AdHocCLI(CLI):
|
||||||
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=self.options.inventory)
|
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=self.options.inventory)
|
||||||
variable_manager.set_inventory(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:
|
if self.options.subset:
|
||||||
inventory.subset(self.options.subset)
|
inventory.subset(self.options.subset)
|
||||||
if len(inventory.list_hosts(pattern)) == 0 and not no_hosts:
|
|
||||||
# Invalid limit
|
hosts = inventory.list_hosts(pattern)
|
||||||
raise AnsibleError("Specified --limit does not match any hosts")
|
if len(hosts) == 0:
|
||||||
|
raise AnsibleError("Specified hosts options do not match any hosts")
|
||||||
|
|
||||||
if self.options.listhosts:
|
if self.options.listhosts:
|
||||||
display.display(' hosts (%d):' % len(hosts))
|
display.display(' hosts (%d):' % len(hosts))
|
||||||
|
|
Loading…
Reference in a new issue