roles/rhel-network: Add static route support
parent
a7ac6c586d
commit
51acc08d3c
|
@ -19,6 +19,19 @@
|
||||||
state=absent
|
state=absent
|
||||||
with_items: '{{ network.ignore_interfaces|d(()) }}'
|
with_items: '{{ network.ignore_interfaces|d(()) }}'
|
||||||
|
|
||||||
|
- name: ensure ipv4 static routes are configured
|
||||||
|
template:
|
||||||
|
src=route.j2
|
||||||
|
dest=/etc/sysconfig/network-scripts/route-{{ item.ifname }}
|
||||||
|
setype=net_conf_t
|
||||||
|
with_items: '{{ network.interfaces }}'
|
||||||
|
- name: ensure ipv6 static routes are configured
|
||||||
|
template:
|
||||||
|
src=route6.j2
|
||||||
|
dest=/etc/sysconfig/network-scripts/route6-{{ item.ifname }}
|
||||||
|
setype=net_conf_t
|
||||||
|
with_items: '{{ network.interfaces }}'
|
||||||
|
|
||||||
- name: ensure network starts at boot
|
- name: ensure network starts at boot
|
||||||
service:
|
service:
|
||||||
name=network
|
name=network
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
{% macro ip_route(route, ifname) %}
|
||||||
|
{% if route.type|d %}{{ route.type }} {% endif %}{{ route.prefix }}{% if route.metric is defined %} metric {{ route.metric }}{% endif %}{% if route.source|d %} src {{ route.source }}{% endif %}{% if route.nexthop|d %}{% for hop in route.nexthop %} {% if loop.length > 1 %}nexthop {% endif %}via {{ hop.address }} dev {{ ifname }}{% if loop.length > 1 and hop.weight is defined %} weight {{ hop.weight }}{% endif %}{% endfor %}{% else %} dev {{ ifname }}{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
{% block routes %}{% endblock %}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{% extends "route-base.j2" %}
|
||||||
|
{% block routes %}
|
||||||
|
{% for route in item.routes|d([]) if ':' not in route.prefix %}
|
||||||
|
{{ ip_route(route, item.ifname) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock routes %}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{% extends "route-base.j2" %}
|
||||||
|
{% block routes %}
|
||||||
|
{% for route in item.routes|d([]) if ':' in route.prefix %}
|
||||||
|
{{ ip_route(route, item.ifname) }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock routes %}
|
Loading…
Reference in New Issue