diff options
author | Jesse Keating <jesse.keating@rackspace.com> | 2014-01-03 16:39:13 -0800 |
---|---|---|
committer | Jesse Keating <jesse.keating@rackspace.com> | 2014-01-03 16:39:13 -0800 |
commit | 35328ed5032643bfc731bacbe74295657436540b (patch) | |
tree | 1fa84ea43af29d064f3bd2b87f62677404c162aa /lib | |
parent | 191be7b951eb8c34b73b367334e0cb4343af0779 (diff) | |
download | ansible-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__.py | 6 |
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 {} |