Ansible templates

{% for host in groups['db_servers'] %}
{{ host }}
{{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}
{% endfor %}

{% elif student.department.upper() != "MATHS DEPARTMENT" %}
Maths department
{% endif %}

# generate SSH config
{% for host in groups['vm.example.com'] %}
Host {{ host }}
Hostname {{ hostvars[host]['ansible_eth0']['ipv4']['address'] }}
{% endfor %}

# Links
http://jinja.pocoo.org/docs/dev/templates/#line-statements