错误!“失败"不是 Play 的有效属性 [英] ERROR! 'fail' is not a valid attribute for a Play
问题描述
我是 Ansible 的新手.以下是我正在尝试播放但面临错误错误!‘失败’不是播放的有效属性"的小片段.
I'm new to Ansible. Below is the small snippet of the playbook which I am trying to play but facing the error "ERROR! 'fail' is not a valid attribute for a Play"
---
- vars_prompt:
- name: "var1"
prompt: "Please pass variable"
private: no
- fail: msg="var1 is not passed or blank"
when: var1 is undefined or ( var1 is defined and storeid == "" )
我尝试了在 stackoverflow 上找到的多个选项,但没有成功.
I have tried multiple options found on stackoverflow but no success.
推荐答案
fail
指令必须在任务级别使用.
这意味着要获得您想要的效果,您必须执行类似的操作
This means that to get your desired effect, you would have to do something like
---
vars_prompt:
- name: "var1"
prompt: "Please pass variable"
private: no
tasks:
- fail: msg="var1 is not passed or blank"
when: var1 is undefined or ( var1 is defined and storeid == "" )
您只需将其余任务放在该声明之后即可.ERROR!'fail' is not a valid attribute for a Play"消息是因为您当前在 Ansible 期望成为播放的嵌套级别声明它.
And you would simply place the rest of your tasks after that declaration. The "ERROR! 'fail' is not a valid attribute for a Play" message is because you're currently declaring it at a nesting level that Ansible is expecting to be a play.
这篇关于错误!“失败"不是 Play 的有效属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!