--- - hosts: all tasks: - name: create a temporary file for additional data file: path: /tmp/tmp-{{Id}} state: touch become: false - name: prepare additional data shell: echo {{additionalData}} > /tmp/tmp-{{Id}} become: false - name: execute post-check operation shell: ./swm/upgrade-post-check {{pnfId}} {{oldSwVersion}} {{targetSwVersion}} {{ruleName}} /tmp/tmp-{{Id}} ignore_errors: yes register: postcheck_result - name: write output to file local_action: copy content="{{postcheck_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt" when: postcheck_result.stdout != "" - name: remove the temporary file file: path: /tmp/tmp-{{Id}} state: absent become: false - name: use result of post-check as the result of Playbook fail: msg: "{{postcheck_result.stderr}}" when: postcheck_result is failed