dont warn on not matching 'all' (#32806)

* dont warn on not matching 'all'

the implicit localhost warning shoudl be enough

* centralized no hosts handling

also extended info on implicit only
This commit is contained in:
Brian Coca 2017-12-15 15:43:51 -05:00 committed by GitHub
commit 87c75b19dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 32 deletions

View file

@ -109,15 +109,7 @@ class PlaybookCLI(CLI):
# limit if only implicit localhost was in inventory to start with.
#
# Fix this when we rewrite inventory by making localhost a real host (and thus show up in list_hosts())
no_hosts = False
if len(inventory.list_hosts()) == 0:
# Empty inventory
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 no_hosts is False:
# Invalid limit
raise AnsibleError("Specified --limit does not match any hosts")
hosts = CLI.get_host_list(inventory, self.options.subset)
# flush fact cache if requested
if self.options.flush_cache: