|
|
|
@ -124,13 +124,17 @@ class AdHocCLI(CLI):
|
|
|
|
|
inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list=self.options.inventory)
|
|
|
|
|
variable_manager.set_inventory(inventory)
|
|
|
|
|
|
|
|
|
|
no_hosts = False
|
|
|
|
|
if len(inventory.list_hosts(pattern)) == 0:
|
|
|
|
|
# Empty inventory
|
|
|
|
|
display.warning("provided hosts list is empty, only localhost is available")
|
|
|
|
|
no_hosts = True
|
|
|
|
|
|
|
|
|
|
if self.options.subset:
|
|
|
|
|
inventory.subset(self.options.subset)
|
|
|
|
|
|
|
|
|
|
hosts = inventory.list_hosts(pattern)
|
|
|
|
|
if len(hosts) == 0:
|
|
|
|
|
raise AnsibleError("Specified hosts options do not match any hosts")
|
|
|
|
|
if len(hosts) == 0 and no_hosts is False:
|
|
|
|
|
# Invalid limit
|
|
|
|
|
raise AnsibleError("Specified --limit does not match any hosts")
|
|
|
|
|
|
|
|
|
|
if self.options.listhosts:
|
|
|
|
|
display.display(' hosts (%d):' % len(hosts))
|
|
|
|
|