From 19fc8eea807547f9945cf1b29a36f2061518ee6d Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Wed, 25 Jul 2012 21:30:49 -0400 Subject: [PATCH] Things that happen inside multiprocessing shouldn't make side effects, ergo append ansible_facts only in playbook code. This technically means with_items calls can't continuously add facts I guess, but I can't see anyone ever trying that. --- lib/ansible/playbook/__init__.py | 5 +++++ lib/ansible/runner/__init__.py | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/playbook/__init__.py b/lib/ansible/playbook/__init__.py index 959a3279f11..77330f438c8 100644 --- a/lib/ansible/playbook/__init__.py +++ b/lib/ansible/playbook/__init__.py @@ -221,6 +221,11 @@ class PlayBook(object): results = {} self.stats.compute(results) + + # add facts to the global setup cache + for host, result in results['contacted'].iteritems(): + facts = result.get('ansible_facts', {}) + self.SETUP_CACHE[host].update(facts) # flag which notify handlers need to be run if len(task.notify) > 0: diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 1af7338cf77..4a0eb761f0f 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -248,8 +248,6 @@ class Runner(object): self.module_args += " #USE_SHELL" exec_rc = self._execute_module(conn, tmp, module_name, self.module_args, inject=inject) - if exec_rc.is_successful(): - self.setup_cache[conn.host].update(exec_rc.result.get('ansible_facts', {})) return exec_rc # *****************************************************