summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJesse Keating <jesse.keating@rackspace.com>2014-01-03 16:39:13 -0800
committerJesse Keating <jesse.keating@rackspace.com>2014-01-03 16:39:13 -0800
commit35328ed5032643bfc731bacbe74295657436540b (patch)
tree1fa84ea43af29d064f3bd2b87f62677404c162aa /lib
parent191be7b951eb8c34b73b367334e0cb4343af0779 (diff)
downloadansible-35328ed5032643bfc731bacbe74295657436540b.tar.gz
Return early from setup step when possible
The _list_available_hosts call can be lengthy, and in the case where gather_facts is disabled the call is pointless. So re-arrange the logic to return early from _do_setup_step when gather_facts is false.
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/playbook/__init__.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py
index e2bd662618..c34973dd75 100644
--- a/lib/ansible/playbook/__init__.py
+++ b/lib/ansible/playbook/__init__.py
@@ -433,11 +433,11 @@ class PlayBook(object):
def _do_setup_step(self, play):
''' get facts from the remote system '''
- host_list = self._list_available_hosts(play.hosts)
-
if play.gather_facts is False:
return {}
- elif play.gather_facts is None:
+
+ host_list = self._list_available_hosts(play.hosts)
+ if play.gather_facts is None:
host_list = [h for h in host_list if h not in self.SETUP_CACHE or 'module_setup' not in self.SETUP_CACHE[h]]
if len(host_list) == 0:
return {}