Skip to content

Commit

Permalink
Sanitize debug var= tasks of the loop variable
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed May 6, 2020
1 parent 366f808 commit 795d7b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/66269-hide-debug-loop-vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "Fixed it so that debug tasks using var option will no longer show loop control variables."
5 changes: 5 additions & 0 deletions lib/ansible/plugins/callback/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ def _clean_results(self, result, task_name):
# 'var' value as field, so eliminate others and what is left should be varname
for hidme in self._hide_in_debug:
result.pop(hidme, None)
# when using loop control, remove these vars in addition to the var they reference
for control_var in ('ansible_loop_var', 'ansible_index_var'):
if control_var in result:
loop_var = result.pop(control_var)
result.pop(loop_var, None)

def set_play_context(self, play_context):
pass
Expand Down

0 comments on commit 795d7b0

Please sign in to comment.