I have a playbook like this below ,i want to control execution of rescue when the block goes wrong。
I add when: is_debug is defined after rescue ,but when i run ansible-playbook dashboard.yml ,not give the is_debug value, the rescue is still excute when block has error .
i want know how to control the execution of rescue module in ansible ?
[root@ansiable-test update]# cat dashboard.yml
---
- hosts: controller
vars_files:
- "vars/vars.yml"
tasks:
- name: update horizon
- block:
- include: "roles/dashboard/tasks/update-horizon.yml"
rescue:
when: is_debug is defined
- debug: msg='An error occurred during the upgrade,roll back to the old version'
- include: "roles/dashboard/tasks/rollback.yml"