Update changed_when and failed_when examples (#50411)

Added examples in playbooks_error_handling doc for handlining
multiple conditions in changed_when and failed_when

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/50498/head
Abhijeet Kasurde 6 years ago committed by Sandra McCann
parent 0a56a22098
commit a45063defe

@ -0,0 +1,2 @@
minor_changes:
- Add examples in documentation to explain how to handle multiple conditions in changed_when and failed_when.

@ -93,6 +93,15 @@ In previous version of Ansible, this can still be accomplished as follows::
msg: "the command failed"
when: "'FAILED' in command_result.stderr"
You can also combine multiple conditions to specify this behavior as follows::
- name: Check if a file exists in temp and fail task if it does
command: ls /tmp/this_should_not_be_here
register: result
failed_when:
- '"No such" not in result.stdout'
- result.rc == 0
.. _override_the_changed_result:
Overriding The Changed Result
@ -116,6 +125,15 @@ does not cause handlers to fire::
- shell: wall 'beep'
changed_when: False
You can also combine multiple conditions to override "changed" result::
- command: /bin/fake_command
register: result
ignore_errors: True
changed_when:
- '"ERROR" in result.stderr'
- result.rc == 2
Aborting the play
`````````````````

Loading…
Cancel
Save