Add quotes to elemens of the list in jinja2 (ansible)

后端 未结 8 446
伪装坚强ぢ
伪装坚强ぢ 2021-01-11 10:43

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.         


        
8条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-11 11:22

    I found the simplest way to do this with an existing Ansible filter is using regex_replace.

    {{ ip | map("regex_replace","(.+)","\'\\1\'") | join(',')}}
    

提交回复
热议问题