make inventory warnings a bit smarter (#46284)

less annoying for common cases
 add comment for 'tricky' conditional
This commit is contained in:
Brian Coca 2018-11-07 11:09:32 -05:00 committed by GitHub
parent 4961f003e5
commit 903cfa63cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -807,7 +807,7 @@ class CLI(with_metaclass(ABCMeta, object)):
no_hosts = False
if len(inventory.list_hosts()) == 0:
# Empty inventory
if C.LOCALHOST_WARNING:
if C.LOCALHOST_WARNING and pattern not in C.LOCALHOST:
display.warning("provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'")
no_hosts = True