I need to create a file via jinja template but facing some issues.
My Variable
my:
acl:
- name: test
allow:
- 0.0.0.0
deny:
- 1.1.1.1
- name: china
allow:
- 1.2.3.4
deny:
- 10.10.10.10
My Task:
- name: Create acl file
template:
force: yes
src: acl.conf.j2
dest: "/etc/nginx/conf.d/{{ item.name }}.conf"
become: yes
with_items:
- "{{ my.acl }}"
My Template
{% for allow in my.acl %}
allow {{allow.allow}};
{% endfor %}
{% for deny in my.acl %}
deny {{deny.deny}};
{% endfor %}
Result china.conf
allow ['0.0.0.0'];
allow ['1.2.3.4'];
deny ['1.1.1.1'];
deny ['10.10.10.10'];
Result test.conf
allow ['0.0.0.0'];
allow ['1.2.3.4'];
deny ['1.1.1.1'];
deny ['10.10.10.10'];
I need in the china file only the ip addresses that are defined in the object china without the [' ']
How can I do this?