ansible 剧本 if else if
ansible playbook if else if
我有几个输出变量。大约有 4 种不同类型的错误条件和一个成功条件,我使用 when
条件检查。但它更像是一个 if else if else if else 条件。如果第一个条件成立,我什至不想检查第二个、第三个和第四个条件并跳到最后的摘要任务。
如何实现。
Ansible is a Configuration Management Tool with which you declare a state, ideally idempotent.
and a single successful condition, which I check using when condition.
因为只有一种正确的状态,所以只能在 playbook 中定义该状态。那就不用检查了。
除此之外,Conditionals
, if you have multiple conditions, you can group them with parentheses.
要实现您的目标,您应该查看 turn ... if then logic into a boolean expression。
此外,SO 上有很多 Q&A 已经回答了您的问题。
- Ansible
if
else
condition based on gathered fact
我有几个输出变量。大约有 4 种不同类型的错误条件和一个成功条件,我使用 when
条件检查。但它更像是一个 if else if else if else 条件。如果第一个条件成立,我什至不想检查第二个、第三个和第四个条件并跳到最后的摘要任务。
如何实现。
Ansible is a Configuration Management Tool with which you declare a state, ideally idempotent.
and a single successful condition, which I check using when condition.
因为只有一种正确的状态,所以只能在 playbook 中定义该状态。那就不用检查了。
除此之外,Conditionals
, if you have multiple conditions, you can group them with parentheses.
要实现您的目标,您应该查看 turn ... if then logic into a boolean expression。
此外,SO 上有很多 Q&A 已经回答了您的问题。
- Ansible
if
else
condition based on gathered fact