Created
November 28, 2018 10:35
-
-
Save versionsix/44b1d7a346496bd4937efb6694fc24f1 to your computer and use it in GitHub Desktop.
Ansible nested template with loop and variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alpha-file | |
{% for student in students %} | |
{{ lookup('template','beta.j2') }} | |
{%endfor%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Beta-File | |
I want to access variable student here | |
{{student}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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