For the ansible variable param I'd like the behaviour that is similar to the following bash code:
echo ${param:+--arg=}$param
It outputs nothing when the variable is undefined or empty. When the variable has a non-empty value it prints --arg=value.
Is this the best that can be done?
- debug:
msg: "{{ (param | default('') | length > 0) | ternary('--arg=', '') + (param | default('')) }}"