Hello All,
I have two tasks and few yaml files. This is obviously not working as all the files (/etc/nginx/myconfigs/{ab01a,ab01b,ab,www}) have variables from *'**www.*yml’, which is the last item in the iteration.
`
-
include_vars: site_{{ item }}.yml
with_items: site_files -
name: Create nginx files in /etc/nginx/myconfigs
template: src=nginx_site.d_conf.j2 dest=/etc/nginx/myconfigs/{{ item }}.conf
with_items: site_files
`
These are the items in ‘site_files’ variable*.*
`
site_files:
- ab01a
- ab01b
- ab
- www
`
These are the yaml files in which I have few variables which I am substituting in the jinja2 template file (nginx_site.d_conf.j2).
`
ab01a.yml
ab01b.yml
ab.yml
www.yml
`
Please help me to tackle this. I am looking out for a way to dynamically include variables from Yaml files and substitute those in template action.
I can do this by including one variable file and a template action at a time, but I am sure there would be a better way to handle this.
Regards,
Vikas