Hello friends.
Given a list of variables like this:
---
nginx_vhosts:
- {domain: "thisisatest.com", usname: "thisisatest"}
- {domain: "example.com", usname: "example"}
- {domain: "company.com", usname: "company"}
assuming that all works fine in Jinja with:
....
{% for vhost in nginx_vhosts %}
server_name {{ vhost.domain }} www.{{ vhost.domain }};
root /home/{{ vhost.usname }}/public_html/;
{% endfor }
...
how to loop over nginx_vhosts.domain so task "template" can generate 1 file
per domain? This task:
- name: Enable Vhost on CentOS OS family
template: src=templates/vhost-nginx.j2
dest=/etc/nginx/conf.d/{% for vhost in nginx_vhosts %}{{
vhost.domain }}.conf{% endfor %}
owner=root
group=root
mode=0644
give me: thisisatest.com.confexample.com.confcompany.com.conf
Already tried this but no luck, gives me 1 file per domain and all files
have all vhosts.domain inside:
- name: Enable Vhost on CentOS OS family
template: src=templates/vhost-nginx.j2
dest=/etc/nginx/conf.d/{{ item.domain }}.conf
owner=root
group=root
mode=0644
with_item: nginx_vhosts
Thank you!
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0673f78f-2f96-421f-aca1-b802d1cca0b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.