From daa319881f584948e27f943d12c2dbed28467d98 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 17 Jun 2015 12:42:47 -0400 Subject: [PATCH] Make sure registered variable message is sent before other messages Avoids a race condition where previously the registered variable message was being sent after the 'host_task_ok' message, meaning the next task may be started before the var is registered, leading to an undefined variable error --- lib/ansible/executor/process/result.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/ansible/executor/process/result.py b/lib/ansible/executor/process/result.py index f0416db852..352b532cd4 100644 --- a/lib/ansible/executor/process/result.py +++ b/lib/ansible/executor/process/result.py @@ -105,7 +105,9 @@ class ResultProcess(multiprocessing.Process): time.sleep(0.1) continue - host_name = result._host.get_name() + # if this task is registering a result, do it now + if result._task.register: + self._send_result(('set_host_var', result._host, result._task.register, result._result)) # send callbacks, execute other options based on the result status # FIXME: this should all be cleaned up and probably moved to a sub-function. @@ -160,10 +162,6 @@ class ResultProcess(multiprocessing.Process): # finally, send the ok for this task self._send_result(('host_task_ok', result)) - # if this task is registering a result, do it now - if result._task.register: - self._send_result(('set_host_var', result._host, result._task.register, result._result)) - except queue.Empty: pass except (KeyboardInterrupt, IOError, EOFError):