how to iterate csv file in ansible

后端 未结 1 1983
无人及你
无人及你 2021-01-22 14:16

i have a jinja2 template including a section that need data from a csv file how can i read a csv file and split it into a list then iterate it in the jinja2 template? sth. like

相关标签:
1条回答
  • 2021-01-22 14:33

    figured a not so good method:

    {% for line in csv_data.split("\n") %}
           {% set list = line.split(",") %}
           {{ list[0] }}={{ list[1] }}
    {% endfor %}
    
    0 讨论(0)
提交回复
热议问题