From 81591009eaf60cccec29829219556fcddc45f0c2 Mon Sep 17 00:00:00 2001 From: Brad Olson Date: Wed, 30 May 2012 15:34:21 -0400 Subject: [PATCH 1/2] Fixed Inventory.get_hosts() ignoring restriction when there are no hosts left. get_hosts() was treating [] (meaning complete restriction, no hosts allowed) the same as None (meaning no restriction, all hosts allowed). Fixed logic. --- lib/ansible/inventory/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/__init__.py b/lib/ansible/inventory/__init__.py index 7c5248896a8..2de5634da1b 100644 --- a/lib/ansible/inventory/__init__.py +++ b/lib/ansible/inventory/__init__.py @@ -89,9 +89,10 @@ class Inventory(object): for host in group.get_hosts(): for pat in patterns: if group.name == pat or pat == 'all' or self._match(host.name, pat): - if not self._restriction: + #must test explicitly for None because [] means no hosts allowed + if self._restriction==None: hosts[host.name] = host - if self._restriction and host.name in self._restriction: + elif host.name in self._restriction: hosts[host.name] = host return sorted(hosts.values(), key=lambda x: x.name) From c34921fe7b979905486eeba8ad24e1dc3fb2df18 Mon Sep 17 00:00:00 2001 From: Brad Olson Date: Wed, 30 May 2012 15:37:14 -0400 Subject: [PATCH 2/2] Removed legacy comment. --- lib/ansible/playbook/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index ee20fdacfd2..4f24d0a9ad0 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -282,7 +282,6 @@ class PlayBook(object): # now with that data, handle contentional variable file imports! if play.vars_files and len(play.vars_files) > 0: rc = self._do_setup_step(play, play.vars_files) - #else: warn "You have a vars_files section but didn't state any vars files?? # run all the top level tasks, these get run on every node for task in play.tasks():