Ansible 任务可以有when这样的子句:
- name: Conditional output
debug:
msg: This is a conditional output
when: some_var
Run Code Online (Sandbox Code Playgroud)
为了防止some_var未定义,可以使用
- name: Conditional output
debug:
msg: This is a conditional output
when: some_var is defined and some_var
Run Code Online (Sandbox Code Playgroud)
似乎还有这样的变体:
- name: Conditional output
debug:
msg: This is a conditional output
when: some_var | d() | bool
Run Code Online (Sandbox Code Playgroud)
这些变体相同吗?它们的优点/缺点是什么?
ansible ×1