summaryrefslogtreecommitdiff
path: root/roles/vm/guest/network/templates/interfaces/simple.j2
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-07-18 20:15:13 +0200
committerChristian Pointner <equinox@spreadspace.org>2020-07-20 23:06:59 +0200
commit0448ed6524ea9fb5f588a51d4316c4db7e8b8a49 (patch)
treedfc70389ed68007fa15907f09c69921704ee832d /roles/vm/guest/network/templates/interfaces/simple.j2
parentgeneric playbooks: cook some variables (diff)
vm/guest/network: simplify template
Diffstat (limited to 'roles/vm/guest/network/templates/interfaces/simple.j2')
-rw-r--r--roles/vm/guest/network/templates/interfaces/simple.j211
1 files changed, 11 insertions, 0 deletions
diff --git a/roles/vm/guest/network/templates/interfaces/simple.j2 b/roles/vm/guest/network/templates/interfaces/simple.j2
new file mode 100644
index 00000000..c5b7dadc
--- /dev/null
+++ b/roles/vm/guest/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 %}