Hello guys,
I'm trying to check if the server is still reachable with a block -rescue statement.
If the server is no longer available, the rescue statement should do something.
This is basically the simple playbook:
---
- name: Verify if host is up
hosts: Server2
gather_facts: no
# ignore_unreachable: true
become: true
tasks:
- block:
- name: Ping the Server
ping:
ignore_unreachable: true
rescue:
- debug:
msg: "The Ping was not successful"
...
The problem is that Playbook aborts directly if the server is not available and does not execute the rescue statement.
I tried the ignore_unreachable statement on all possible positions. I have also added the statement ignore_errors.
If im doing it without block / rescue, it is working without any problems.
So the Question: Can the keyword "ignore_unreachable" not be used in a block - rescue statement?