summaryrefslogtreecommitdiff
path: root/roles/vm/guest/network/templates/interfaces/simple.j2
blob: 67665f57a631963f88a69da6cf69a8dc46e13803 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  address {{ interface.address | ansible.utils.ipaddr('address') }}
  netmask {{ interface.address | ansible.utils.ipaddr('netmask') }}
{% if 'gateway' in interface %}
  gateway {{ interface.gateway }}
{% endif %}
{% for address in interface.additional_addresses | default([]) %}
  up /bin/ip addr add dev $IFACE {{ address }}/32
{% endfor %}
{% for route in interface.static_routes | default([]) %}
  up /bin/ip route add {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}{{ '' }}
{% endfor %}
{% for route in interface.static_routes | default([]) | reverse %}
  down /bin/ip route del {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}{{ '' }}
{% endfor %}
{% for address in interface.additional_addresses | default([]) | reverse %}
  down /bin/ip addr del dev $IFACE {{ address }}/32
{% endfor %}