diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2016-09-28 11:21:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-28 11:21:07 -0400 |
commit | 368497fd149838f00b02a2197d94c0717bc5ccd5 (patch) | |
tree | 0a8c3710cf74839c88d055a09e6ead12d804879e | |
parent | 86ea21a73d0956c0ceac7c81a01d58892f8575a1 (diff) | |
download | ansible-368497fd149838f00b02a2197d94c0717bc5ccd5.tar.gz |
better handling of host lists (#17781)
* better handling of host lists
fixes #17762
* corrected message
* fixed extras space
-rw-r--r-- | lib/ansible/cli/adhoc.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index 1b615473e0..f5a3e10982 100644 --- a/lib/ansible/cli/adhoc.py +++ b/lib/ansible/cli/adhoc.py @@ -139,9 +139,12 @@ class AdHocCLI(CLI): inventory.subset(self.options.subset) hosts = inventory.list_hosts(pattern) - if len(hosts) == 0 and no_hosts is False: - # Invalid limit - raise AnsibleError("Specified hosts and/or --limit does not match any hosts") + if len(hosts) == 0: + if no_hosts is False and self.options.subset: + # Invalid limit + raise AnsibleError("Specified --limit does not match any hosts") + else: + display.warning("No hosts matched, nothing to do") if self.options.listhosts: display.display(' hosts (%d):' % len(hosts)) |