You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---
- name: Rescue Example
hosts: all
gather_facts: false
tasks:
- name: Handle the error
block:
- name: Print a message
ansible.builtin.debug:
msg: 'I execute normally'
- name: Force a failure
ansible.builtin.command: /bin/false
- name: Never print this
ansible.builtin.debug:
msg: 'I never execute, due to the above task failing, :-('
rescue:
- name: Print when errors
ansible.builtin.debug:
msg: 'I caught an error, can do stuff here to fix it, :-)'
always:
- name: Always do this
ansible.builtin.debug:
msg: "This always executes, :-)"
The text was updated successfully, but these errors were encountered:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html#id4
The text was updated successfully, but these errors were encountered: