如何控制ansible中救援模块的执行
我有一本下面这样的剧本,我想在方块出错时控制救援的执行 在rescue后定义了is_debug时,我添加了如何控制ansible中救援模块的执行,ansible,Ansible,我有一本下面这样的剧本,我想在方块出错时控制救援的执行 在rescue后定义了is_debug时,我添加了,但当我运行ansible playbook dashboard.yml时,没有给出is_debug值,当块出错时,仍然执行rescue 我想知道如何控制ansible中救援模块的执行 [root@ansiable-test update]# cat dashboard.yml --- - hosts: controller vars_files: - "vars/var
,但当我运行ansible playbook dashboard.yml时,没有给出is_debug值,当块出错时,仍然执行rescue
我想知道如何控制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"
没有救援
“模块”。它是块
语法的一部分,当
仅应用于救援
部分时,不能应用。您可以将when
条件应用于rescue
节中的任务:
- hosts: controller
vars_files:
- "vars/vars.yml"
tasks:
- name: update horizon
- block:
- include: "roles/dashboard/tasks/update-horizon.yml"
rescue:
- debug: msg='An error occurred during the upgrade,roll back to the old version'
when: is_debug is defined
- include: "roles/dashboard/tasks/rollback.yml"
when: is_debug is defined