Based on extra vars parameter I Need to write variable value in ansible playbook
extra vars
ansible playbook
ansible-playbook playbook.yml -e \"param1=value1 param
I would first suggest that you step back and look at organizing your plays to not require such complexity, but if you really really do, use the following:
vars: myvariable: "{{[param1|default(''), param2|default(''), param3|default('')]|join(',')}}"