Ansible jinja 模板 trim 最后一个字符
Ansible jinja templating trim last character
我想要这个输出ingress = ["aa","bb"]
- name: Create the Jinja2 based template
template:
src: "/var/opt/conf.yml.j2"
dest: "/var/opt/conf.yml"
with_items: "{{ var }}"
ingress = [{% for item in var.stdout_lines %} "{{ item }}", {% endfor %}]
但我在列表末尾有一个 ,
ingress = ["aa","bb",]
我怎么会trim最后一个字符,
{% for item in var.stdout_lines %} "{{ item }}" {%if not loop.last %},{% endif %}{% endfor %}
我想要这个输出ingress = ["aa","bb"]
- name: Create the Jinja2 based template
template:
src: "/var/opt/conf.yml.j2"
dest: "/var/opt/conf.yml"
with_items: "{{ var }}"
ingress = [{% for item in var.stdout_lines %} "{{ item }}", {% endfor %}]
但我在列表末尾有一个 ,
ingress = ["aa","bb",]
我怎么会trim最后一个字符,
{% for item in var.stdout_lines %} "{{ item }}" {%if not loop.last %},{% endif %}{% endfor %}