I've written the following playbook. I expect an error from the second play, but the first and third to run. What I get is the first running, the second failing, and the third is completely ignored.
If I make the second play succeed then the third play works.
How can I get the third play to execute even when the second play fails?
- name: First local task
hosts: localhost
tasks:
- add_host:
name: dummy.example.com
groups: test
- name: Failing remote host
hosts: test
tasks:
- debug:
msg: 'test'
- name: "This one should run too?"
hosts: localhost
tasks:
- debug:
msg: 'success!'
You didn't specify the exact error in your question. However generally you can add
ignore_errors: yes
to your second task to proceed with the third task, even if errors occur. If the error, is that your host "test" isn't reachable than you have to useignore_unreachable: yes
like below: