I am learning ansible. i have written a jinja2 template for looping over a multiple values. However, i get those values from a linux command.
- name: fetching port ranges
command: ls /apache |grep redis|grep ".pid" | awk -F"_" '{ print $2}'| awk -F"." '{print $1}'
Output of the above command will be :
10001
10002
10003
10004
10005
Below is the jinja2 template
[{% for range in port %}
"127.0.0.1:{{ range }}",
{% endfor %}]
With "for loop" in the jinja2 template, i am trying iterate over the values generated by linux command but i am not sure how to save those values and use it in jinja2 template. Any help would be appreciated.