ansible-role-network/templates/interfaces.j2
2021-08-24 19:53:34 +02:00

24 lines
699 B
Django/Jinja

# {{ ansible_managed }}
auto lo
iface lo inet loopback
{% for interface_name, interface in network_interfaces.items() %}
auto {{ interface_name }}
{% if interface.dhcp is defined and interface.dhcp %}
iface {{ interface_name }} inet dhcp
{% else %}
iface {{ interface_name }} inet static
address {{ interface.address }}
netmask {{ interface.netmask }}
{% if interface.gateway is defined %}
gateway {{ interface.gateway }}
{% endif %}
{% endif %}
{% if interface.routes is defined %}
{% for route in interface.routes %}
post-up ip route add {{ route.subnet }} via {{ route.gateway }}
post-down ip route del {{ route.subnet }} via {{ route.gateway }}
{% endfor %}
{% endif %}
{% endfor %}