I have a list of strings containing IP addresses. I want to add a port number to each of them. In python, I would do it something like this:
ip_list = [(ip + ":" + port) for ip in ip_list]
... but Jinja does not support lists. At the moment, I am complicating the task of creating a new list one item at a time:
{%- set ip_list = magic() %}
{%- set new_ip_list = [] %}
{%- for ip in ip_list %}
{%- do new_ip_list.append(ip + ":" + port) %}
{%- endfor %}
It's ugly and annoying in the middle of the template, and it seems that there really needs to be a better way to get the job done. Preferably single line.
As long as I know that this can be done using custom filters, I supply a template for software that I did not write (salt plate), so they (as far as I know) are not available to me.
source
share