是否可以創建一個將變量放在一行上的jinja2模板?像這樣的東西,而不是在結果中有兩行用逗號分隔。Jinja2模板變量爲一行
模板:
{% for host in groups['tag_Function_logdb'] %}
elasticsearch_discovery_zen_ping_unicast_hosts = {{ host }}:9300
{% endfor %}
結果:
elasticsearch_discovery_zen_ping_unicast_hosts = 1.1.1.1:9300
elasticsearch_discovery_zen_ping_unicast_hosts = 2.2.2.2:9300
期望的結果:
elasticsearch_discovery_zen_ping_unicast_hosts = 1.1.1.1:9300,2.2.2.2:9300
編輯,這個工程:
elasticsearch_discovery_zen_ping_unicast_hosts = {% for host in groups['tag_Function_logdb'] %}
{{ host }}:9300
{%- if loop.first %},{% endif %}
{% endfor %}
的可能的複製[逗號如何輸出分隔在神社蟒蛇模板列表?(http://stackoverflow.com/questions/11974318/how-to-output-a-comma-delimited-list- in-jinja-python-template) – nelsonda