我在看一些有趣的例子,发现了following example:
tasks:
- shell: echo "I've got '{{ foo }}' and am not afraid to use it!"
when: foo is defined
- fail: msg="Bailing out. this play requires 'bar'"
when: bar is undefined
让我们说,如果“ somevar已定义”,我们只想运行以下任何任务
tasks:
- shell: echo "1"
when: foo is defined
- shell: echo "2"
when: barone is defined
- shell: echo "3"
when: bartwo is defined
- shell: echo "4"
when: bar is undefined
是否可以一次将“何时”添加多个任务? 我想避免以下情况
tasks:
- shell: echo "1"
when:
-foo is defined
-somevar is defined
- shell: echo "2"
when:
-barone is defined
-somevar is defined
注意多次(假设有100个任务)。