I have very simple line in the template:
ip={{ip|join(\', \')}}
And I have list for ip:
ip: - 1.1.1.1 - 2.2.2.2 - 3.3.3.
I found the simplest way to do this with an existing Ansible filter is using regex_replace.
regex_replace
{{ ip | map("regex_replace","(.+)","\'\\1\'") | join(',')}}