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

@ -426,16 +426,7 @@ class ConsoleCLI(CLI, cmd.Cmd):
ask_vault_pass=self.options.ask_vault_pass)
self.loader.set_vault_secrets(vault_secrets)
no_hosts = False
if len(self.inventory.list_hosts()) == 0:
# Empty inventory
no_hosts = True
display.warning("provided hosts list is empty, only localhost is available")
self.inventory.subset(self.options.subset)
hosts = self.inventory.list_hosts(self.pattern)
if len(hosts) == 0 and not no_hosts:
raise AnsibleError("Specified hosts and/or --limit does not match any hosts")
hosts = CLI.get_host_list(self.inventory, self.options.subset, self.pattern)
self.groups = self.inventory.list_groups()
self.hosts = [x.name for x in hosts]