mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 14:01:42 -07:00
fixed confusing reporting when no hosts are matched
it was hitting 'empty inventory' warning.
This commit is contained in:
parent
01decf4166
commit
4c3c294a03
2 changed files with 11 additions and 5 deletions
|
@ -130,7 +130,7 @@ class AdHocCLI(CLI):
|
|||
variable_manager.set_inventory(inventory)
|
||||
|
||||
no_hosts = False
|
||||
if len(inventory.list_hosts(pattern)) == 0:
|
||||
if len(inventory.list_hosts()) == 0:
|
||||
# Empty inventory
|
||||
display.warning("provided hosts list is empty, only localhost is available")
|
||||
no_hosts = True
|
||||
|
@ -139,7 +139,7 @@ class AdHocCLI(CLI):
|
|||
hosts = inventory.list_hosts(pattern)
|
||||
if len(hosts) == 0 and no_hosts is False:
|
||||
# Invalid limit
|
||||
raise AnsibleError("Specified --limit does not match any hosts")
|
||||
raise AnsibleError("Specified hosts and/or --limit does not match any hosts")
|
||||
|
||||
if self.options.listhosts:
|
||||
display.display(' hosts (%d):' % len(hosts))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue