如何跳过Ansible中的剩余任务并创建特定条件
我想在下面创建以下条件。有什么办法吗?我尝试过当条件、设置事实、循环[],但我没有成功。我们将非常感谢您的帮助 已生成的变量示例:如何跳过Ansible中的剩余任务并创建特定条件,ansible,Ansible,我想在下面创建以下条件。有什么办法吗?我尝试过当条件、设置事实、循环[],但我没有成功。我们将非常感谢您的帮助 已生成的变量示例: version_detected: "9.0.0.7" version_available: "9.1.0.3" "9.0.0.7", "8.0.0.13" 创建一个条件,其中 If "version_detected" is inside "version_availabl
version_detected: "9.0.0.7"
version_available: "9.1.0.3"
"9.0.0.7",
"8.0.0.13"
创建一个条件,其中
If "version_detected" is inside "version_available", then skip all remaining tasks and end playbook with a debug message.
If "version_detected" is not inside "version_available", then continue playbook for the next task.
下一个任务:
If "version_detected" contains "8.0", then download file www.site.com/fixpack80.gz to path
If "version_detected" contains "9.0", then download file www.site.com/fixpack90.gz to path
If "version_detected" contains "9.1", then download file www.site.com/fixpack91.gz to path
假设可用的
version\u
是一个列表,则只有在条件下才能实现这一点
例如:
vars:
version_detected: "9.0.0.7"
version_available: ["9.1.0.3", "9.0.0.7", "8.0.0.13"]
tasks:
- fail:
msg: Unsupported version
when: version_detected not in version_available
- debug:
msg: Do some task for version 8.0.x.x
when: '"8.0" in version_detected'
- debug:
msg: Do some task for version 9.0.x.x
when: '"9.0" in version_detected'