Thank you for the hints. I’m absolutely far for being an Ansible expert.
We have several roles, like the example what is imported and we cannot afford to fail any of our command on one host and keep the playbook run on the remaining ones. Therefore I’m looking for a solution which fail the entire playbook as soon as any error occurs, but saves the facts and push the error messages ( as you can see from my code ).
I’ve only read some pieces of information, that callbacks can be the solution, but I’m an Exadata architect, I have no skills on python. Can u tell me more about this possibility?
Also about " his is better done via a callback. Some like mail
already record failures and send to a specified address, the same can be done to disk/system log/etc."
I share the output. I’m testing if a given RHEL repo is enabled or not ( this is just for testing purposes ). I set “enabled=0” on one of our hosts to see, if I can fail the entire playbook when an error occurs only on one host. As you can see from the output, the role keeps going to the next module ( and then finishes, because that’s the end of the test role ).
Here comes the content of the imported role:
- name: Ksplice_actions
become: yes
shell: dnf repoinfo ol8_x86_64_ksplice -v | grep -i ^Repo-status | grep enabled
register: var_repo_status
failed_when: var_repo_status.rc != 0
- name: Results_of_Ksplice_action
debug: msg="{{ var_repo_status.stdout_lines }}"
- name: Get_Ksplice_update_version
shell: dnf --showduplicates list uptrack-updates-$(uname -r) | sort --reverse | head -1 | awk '{print $1}'
register: var_ksplice_version
- name: Show_Ksplice_version
debug: msg="Ksplice version is {{ var_ksplice_version.stdout }}"
Output:
Results_of_Ksplice_action showing only 1 enabled ->expected, that is OK
Get_Ksplice_update_version → That shouldn’t run, by this time Ansible should have failed, because on one host, there is no enbaled repo.
TASK [OCI_POST_PATCH_VMCLUSTER_OS_DOWNTIME : Ksplice_actions] ****************************************************************************************************************************************************
Thursday 17 July 2025 21:19:58 +0200 (0:00:00.101) 0:00:00.252 *********
fatal: [44.144.212.92]: FAILED! => {"changed": true, "cmd": "dnf repoinfo ol8_x86_64_ksplice -v | grep -i ^Repo-status | grep enabled", "delta": "0:00:03.269648", "end": "2025-07-17 21:20:01.987667", "failed_when_result": true, "msg": "non-zero return code", "rc": 1, "start": "2025-07-17 21:19:58.718019", "stderr": "Last metadata expiration check: 1:29:04 ago on Thu 17 Jul 2025 07:50:55 PM CEST.", "stderr_lines": ["Last metadata expiration check: 1:29:04 ago on Thu 17 Jul 2025 07:50:55 PM CEST."], "stdout": "", "stdout_lines": []}
changed: [44.144.212.35]
TASK [OCI_POST_PATCH_VMCLUSTER_OS_DOWNTIME : Results_of_Ksplice_action] ******************************************************************************************************************************************
Thursday 17 July 2025 21:20:03 +0200 (0:00:05.009) 0:00:05.261 *********
ok: [44.144.212.35] => {
"msg": [
"Repo-status : enabled"
]
}
TASK [OCI_POST_PATCH_VMCLUSTER_OS_DOWNTIME : Get_Ksplice_update_version] *****************************************************************************************************************************************
Thursday 17 July 2025 21:20:03 +0200 (0:00:00.089) 0:00:05.351 *********
changed: [44.144.212.35]
TASK [OCI_POST_PATCH_VMCLUSTER_OS_DOWNTIME : Show_Ksplice_version] ***********************************************************************************************************************************************
Thursday 17 July 2025 21:20:08 +0200 (0:00:05.122) 0:00:10.473 *********
ok: [44.144.212.35] => {
"msg": "Ksplice version is uptrack-updates-5.4.17-2136.330.7.5.el8uek.x86_64.noarch"
}
TASK [MAIN_PRINT_FAILED_TASK] ************************************************************************************************************************************************************************************
Thursday 17 July 2025 21:20:08 +0200 (0:00:00.239) 0:00:10.713 *********
fatal: [44.144.212.92 -> localhost]: FAILED! => {"changed": false, "msg": "[LOG] : [2025-07-17T21:20.08] : [FAILURE] : FAILED_TASK: OCI_POST_PATCH_VMCLUSTER_OS_DOWNTIME.yaml/Ksplice_actions. Exiting ..."}
TASK [MAIN_SAVE_FACTS] *******************************************************************************************************************************************************************************************
Thursday 17 July 2025 21:20:08 +0200 (0:00:00.153) 0:00:10.866 *********
included: /home/k8ra9vk/patch_exadata_ansible/common_tasks/handle_facts.yml for 44.144.212.92