Hello Everyone, I solved my issue using these two links.
http://stackoverflow.com/questions/26606121/ansible-loop-over-variables http://tiku.io/questions/539822/how-to-loop-over-array-containing-template-variables-with-ansible Hope this helps someone who is facing the same problem. Regards, Vikas On Thursday, 14 May 2015 14:18:32 UTC+10, Vikas Kumar wrote: > > 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 > -- 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/e9225d27-312c-49fa-b14e-c4ba4b8a3cf7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
