Skip to content

Commit 19fc8ee

Browse files
committed
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.
1 parent 51739fc commit 19fc8ee

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/ansible/playbook/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ def _run_task(self, play, task, is_handler):
221221
results = {}
222222

223223
self.stats.compute(results)
224+
225+
# add facts to the global setup cache
226+
for host, result in results['contacted'].iteritems():
227+
facts = result.get('ansible_facts', {})
228+
self.SETUP_CACHE[host].update(facts)
224229

225230
# flag which notify handlers need to be run
226231
if len(task.notify) > 0:

lib/ansible/runner/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,6 @@ def _execute_normal_module(self, conn, tmp, module_name, inject=None):
248248
self.module_args += " #USE_SHELL"
249249

250250
exec_rc = self._execute_module(conn, tmp, module_name, self.module_args, inject=inject)
251-
if exec_rc.is_successful():
252-
self.setup_cache[conn.host].update(exec_rc.result.get('ansible_facts', {}))
253251
return exec_rc
254252

255253
# *****************************************************

0 commit comments

Comments
 (0)