From 35328ed5032643bfc731bacbe74295657436540b Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Fri, 3 Jan 2014 16:39:13 -0800 Subject: [PATCH] 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. --- lib/ansible/playbook/__init__.py | 6 +++--- 1 file 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 {}