I'm trying to set a template that pulls in a comma separated list of hosts, and appends a port to each host.
The list, an ansible fact: {{ nodes }}) looks like this:
node1,node2,node3,...,nodeX
And I want the final templated file to look like this:
node1:1234
node2:1234
node3:1234
...
nodeX:1234
My jinja template currently looks like:
"{{ nodes.split(',') | to_nice_json | indent(8) }}"
Which gets me:
node1,
node2,
node3,
...,
nodeX
But, how can I append the port to each node?
I've tried various combinations of
-
{{ nodes.split(',') | join(':1234) | to_nice_json | indent(8) }} -
{{ nodes.split(',') | + (':1234) | to_nice_json | indent(8) }} -
{% for n in {{ nodes.split(,) }} | zip(':1234') %} {{ n[0]n[1] }} {% endfor %} etc