From a259b95556969095b8173ca18cb7e466e3573de3 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Thu, 15 Nov 2012 15:25:28 +0100 Subject: [PATCH] Fail ansible-playbook when the hosts list (with applied subset) is empty When the inventory is empty, or the provided --limit subset returns an empty intersection, we don't want to loop over all plays but bail out at the very start. --- bin/ansible-playbook | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/ansible-playbook b/bin/ansible-playbook index 13db4872dc..c0ad500d9d 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -68,6 +68,11 @@ def main(args): parser.print_help(file=sys.stderr) return 1 + inventory = ansible.inventory.Inventory(options.inventory) + inventory.subset(options.subset) + if len(inventory.list_hosts()) == 0: + raise errors.AnsibleError("provided hosts list is empty") + sshpass = None sudopass = None if not options.listhosts: