tasks:\r
\r
- name: execute swFallback operation\r
- shell: ./swm/swFallback.sh --filter {{filter}}\r
- register: fallback__result\r
+ shell: ./swm/swFallback --filter {{filter}}\r
+ ignore_errors: yes\r
+ register: fallback_result\r
+ \r
+ - name: write output to file\r
+ local_action: copy content="{{fallback_result.stdout}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+ when: fallback_result.stdout != ""\r
+\r
+ - name: build error message\r
+ set_fact:\r
+ err_msg:\r
+ "reason": "{{fallback_result.stderr}}"\r
+ "result": "Failure"\r
+ when: fallback_result is failed and fallback_result.stdout == "" and fallback_result.stderr != ""\r
+\r
+ - name: write error message to file\r
+ local_action: copy content="{{err_msg}}" dest="{{inventory_dir}}/{{inventory_hostname}}_results.txt"\r
+ when: fallback_result is failed and fallback_result.stdout == "" and fallback_result.stderr != ""\r
+\r
+ - name: use result of swFallback as the result of Playbook\r
+ fail:\r
+ msg: "{{fallback_result.stderr}}"\r
+ when: fallback_result is failed\r
\r