Template Calls List of Variables to Build Config

15 views
Skip to first unread message

Chris Short

unread,
Feb 20, 2015, 10:28:16 AM2/20/15
to ansible...@googlegroups.com
I'm trying to simplify a DNS sinkhole configuration with Ansible. Ultimately what I'd like is a file full of domains (potentially hundreds). I'd then like a template that has one line that iterates through the list of domains build a config file. The config file is essentially multiple similar lines where the only thing that changes is the domain. I'm not quite sure how to get Ansible/Jinja to do this for me though. Thoughts?

Brian Coca

unread,
Feb 20, 2015, 10:34:02 AM2/20/15
to ansible...@googlegroups.com
something like:

vars:
sinkhole:
- host1
- fqdn2.exmaple.com
....


- template: src=sinkhole.j2 ....



---------
sinkhole.j2

{% for host in sinkhole %}
{{ host }} 127.0.0.1
{% endfor %}



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages