1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Exit 0 with no matched hosts

And also print to stdout not err

This lines up with how ansible-playbook will exit. 0 in the case of no
matched hosts. This makes it easier to script ansible commands w/
variable iventory input which may or may not have an entry for the
specific ansible task being scripted. No matched hosts is acceptable,
but matched hosts w/ failures is not.
This commit is contained in:
Jesse Keating 2013-11-05 21:37:31 -08:00
parent 5eab293421
commit 46554bbc30

View file

@ -81,8 +81,8 @@ class Cli(object):
inventory_manager.subset(options.subset) inventory_manager.subset(options.subset)
hosts = inventory_manager.list_hosts(pattern) hosts = inventory_manager.list_hosts(pattern)
if len(hosts) == 0: if len(hosts) == 0:
callbacks.display("No hosts matched", stderr=True) callbacks.display("No hosts matched")
sys.exit(1) sys.exit(0)
if options.listhosts: if options.listhosts:
for host in hosts: for host in hosts: