Skip to content

Instantly share code, notes, and snippets.

@skamithi
Created March 5, 2018 16:54
Show Gist options
  • Save skamithi/66afd156bf2463c5987468e18f4d6bbc to your computer and use it in GitHub Desktop.
Save skamithi/66afd156bf2463c5987468e18f4d6bbc to your computer and use it in GitHub Desktop.
test123
---
- hosts: localhost
connection: local
tasks:
- name: run a shell command
shell: cat /tmp/123
register: shell_output
# failed_when: false # do not print out json blob if it fails
ignore_errors: yes # print out json blob with error message
changed_when: false
- name: print out the message if its a standard error
debug:
msg: "Error message is {{ shell_output.stderr }}"
when: shell_output.rc != 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment