From 46554bbc30d00a91e96fc0b7e051d5c33cf9d0d3 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Tue, 5 Nov 2013 21:37:31 -0800 Subject: [PATCH] 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. --- bin/ansible | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ansible b/bin/ansible index f8c72234c8..3d4cb07ad9 100755 --- a/bin/ansible +++ b/bin/ansible @@ -81,8 +81,8 @@ class Cli(object): inventory_manager.subset(options.subset) hosts = inventory_manager.list_hosts(pattern) if len(hosts) == 0: - callbacks.display("No hosts matched", stderr=True) - sys.exit(1) + callbacks.display("No hosts matched") + sys.exit(0) if options.listhosts: for host in hosts: