Skip to content

Commit

Permalink
Wrap all results, regardless of register, except for actions with cle…
Browse files Browse the repository at this point in the history
…an facts. Fixes ansible#21088
  • Loading branch information
sivel committed Jan 8, 2021
1 parent 5e03e32 commit cd54056
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/ansible/executor/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,13 +591,16 @@ def _execute(self, variables=None):
# preserve no log
result["_ansible_no_log"] = self._play_context.no_log

if self._task.action not in C._ACTION_WITH_CLEAN_FACTS:
result = wrap_var(result)

# update the local copy of vars with the registered value, if specified,
# or any facts which may have been generated by the module execution
if self._task.register:
if not isidentifier(self._task.register):
raise AnsibleError("Invalid variable name in 'register' specified: '%s'" % self._task.register)

vars_copy[self._task.register] = result = wrap_var(result)
vars_copy[self._task.register] = result

if self._task.async_val > 0:
if self._task.poll > 0 and not result.get('skipped') and not result.get('failed'):
Expand Down Expand Up @@ -649,12 +652,15 @@ def _evaluate_failed_when_result(result):
if 'changed' not in result:
result['changed'] = False

if self._task.action not in C._ACTION_WITH_CLEAN_FACTS:
result = wrap_var(result)

# re-update the local copy of vars with the registered value, if specified,
# or any facts which may have been generated by the module execution
# This gives changed/failed_when access to additional recently modified
# attributes of result
if self._task.register:
vars_copy[self._task.register] = result = wrap_var(result)
vars_copy[self._task.register] = result

# if we didn't skip this task, use the helpers to evaluate the changed/
# failed_when properties
Expand Down Expand Up @@ -682,10 +688,13 @@ def _evaluate_failed_when_result(result):
result['attempts'] = retries - 1
result['failed'] = True

if self._task.action not in C._ACTION_WITH_CLEAN_FACTS:
result = wrap_var(result)

# do the final update of the local variables here, for both registered
# values and any facts which may have been created
if self._task.register:
variables[self._task.register] = result = wrap_var(result)
variables[self._task.register] = result

if 'ansible_facts' in result:
if self._task.action in C._ACTION_WITH_CLEAN_FACTS:
Expand Down

0 comments on commit cd54056

Please sign in to comment.