Skip to content

Instantly share code, notes, and snippets.

@versionsix
Created November 28, 2018 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save versionsix/44b1d7a346496bd4937efb6694fc24f1 to your computer and use it in GitHub Desktop.
Save versionsix/44b1d7a346496bd4937efb6694fc24f1 to your computer and use it in GitHub Desktop.
Ansible nested template with loop and variable
Alpha-file
{% for student in students %}
{{ lookup('template','beta.j2') }}
{%endfor%}
Beta-File
I want to access variable student here
{{student}}
---
- hosts: localhost
connection: local
gather_facts: false
vars:
students:
- Alex
- Ruby
tasks:
- debug:
msg: "{{ lookup('template','alpha.j2')}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment