summaryrefslogtreecommitdiff
path: root/roles/vm/host/network/templates/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'roles/vm/host/network/templates/interfaces')
-rw-r--r--roles/vm/host/network/templates/interfaces/simple.j211
-rw-r--r--roles/vm/host/network/templates/interfaces/simple6.j210
2 files changed, 21 insertions, 0 deletions
diff --git a/roles/vm/host/network/templates/interfaces/simple.j2 b/roles/vm/host/network/templates/interfaces/simple.j2
new file mode 100644
index 00000000..c5b7dadc
--- /dev/null
+++ b/roles/vm/host/network/templates/interfaces/simple.j2
@@ -0,0 +1,11 @@
+ address {{ interface.address | ipaddr('address') }}
+ netmask {{ interface.address | ipaddr('netmask') }}
+{% if 'gateway' in interface %}
+ gateway {{ interface.gateway }}
+{% endif %}
+{% 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 %}
diff --git a/roles/vm/host/network/templates/interfaces/simple6.j2 b/roles/vm/host/network/templates/interfaces/simple6.j2
new file mode 100644
index 00000000..37fda07a
--- /dev/null
+++ b/roles/vm/host/network/templates/interfaces/simple6.j2
@@ -0,0 +1,10 @@
+ address {{ interface.address6 }}
+{% if 'gateway6' in interface %}
+ gateway {{ interface.gateway6 }}
+{% endif %}
+{% for route in interface.static_routes6 | default([]) %}
+ up /bin/ip -6 route add {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}
+{% endfor %}
+{% for route in interface.static_routes6 | default([]) | reverse %}
+ down /bin/ip -6 route del {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}
+{% endfor %}