--- - set_fact: tox_command_line: "{{ tox_command_line | replace('\n', '') }}" - debug: var=tox_command_line - name: "Run test cases: {{ tox_command_line }}" become: true become_user: stack shell: cmd: | sudo su -l stack -c "cd '{{ test_dir }}' && {{ tox_command_line }}" 2>&1 rc=$? echo "*** FINISHED ***" exit $rc register: run_tox ignore_errors: true - name: Show test cases output debug: var=run_tox.stdout_lines failed_when: run_tox is failed