Hi Arbab, Here you go.
I have multiple fact files generated thru YAML files. Consider below yaml file as an example, which I have converted into JSON and placed in ansible facts directory. See this thread <http://stackoverflow.com/questions/32321911/ansible-iterate-and-include-multiple-variable-files> for converting YAML into JSON and store them as facts. --- app_name: dev1 apps.d: port: 1234 server: test1 instance: dev When iterating over ansible facts, I didn't wanted to hard code anything in playbooks or Jinja2 templates, thus below variables becomes very handy. {% set nginx_dir = item.value.keys().1 %} {% set my_port = item.value[nginx_dir].port %} {% set my_instance = item.value[nginx_dir].instance %} Here, the first line will have apps.d variable in nginx_dir and second line will have 1234 in my_port variable and so on. Now, you can these use variables in the Jinja2 template. Hope this helps. Regards, Vikas On Friday, 9 October 2015 03:10:43 UTC+11, Arbab Nazar wrote: > > @vikas, can you please share the complete example, so that it will help > others. Thanks > > On Wednesday, October 7, 2015 at 8:58:55 PM UTC-4, Vikas Kumar wrote: >> >> Thanks Brian, that is a neat option. >> >> On Thursday, 8 October 2015 05:57:06 UTC+11, Brian Coca wrote: >>> >>> this should also work: >>> {{ item.value[abcd]port }} >>> >>> >>> -- >>> Brian Coca >>> >> -- 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/816fcb0e-66b4-456a-b86b-25ee2d9895b4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
