Some data used in an ansible role:
list1:
- foo
- bar
list2: # sometimes this is empty
This ansible task fails:
- name: hello
somemodule:
dosomething: "{{ list1 + list2 }}"
Error:
fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{list1 + list2}}): can only concatenate list (not \"NoneType\") to list"}
Is there a way to conditionally concatenate only if list2 is not empty?