【发布时间】:2020-05-22 19:18:29
【问题描述】:
一些用于 ansible 角色的数据:
list1:
- foo
- bar
list2: # sometimes this is empty
这个ansible任务失败了:
- name: hello
somemodule:
dosomething: "{{ list1 + list2 }}"
错误:
致命:[本地主机]:失败! => {"msg": "({{list1 + list2}}) 发生意外的模板类型错误:只能将列表(不是 \"NoneType\")连接到列表"}
有没有办法仅在list2 不为空时进行条件连接?
【问题讨论】: