ansible-network-config/templates/interfaces.j2

153 lines
4.4 KiB
Plaintext
Raw Normal View History

2020-07-30 07:34:46 +00:00
auto lo
iface lo inet loopback
{% if host_loopback_IP is defined %}
auto lo:1
iface lo:1 inet static
address {{host_loopback_IP}}/32
{% endif %}
{% if OOBNET_NIC is defined %}
auto {{OOBNET_NIC}}
allow-hotplug {{OOBNET_NIC}}
iface {{OOBNET_NIC}} inet static
address {{OOBNET_IP}}/{{OOBNET_Netmask}}
2020-11-02 06:45:11 +00:00
{% if OOBNET_GW is defined %}gateway {{OOBNET_GW}}{% endif %}
2020-07-30 07:34:46 +00:00
{% endif %}
{% if autobgp_interfaces is defined %}
2021-03-25 07:22:26 +00:00
{% for item in autobgp_interfaces %}
2020-07-30 07:34:46 +00:00
auto {{ item['name'] }}
allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet static
address {{host_loopback_IP}}/32
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
2021-03-25 07:22:26 +00:00
{% if item['force10G'] is defined and item['force10G']|lower == "true" %}
2020-07-30 07:34:46 +00:00
#Force speed to 10G
post-up sudo ethtool -s {{ item['name'] }} autoneg off
post-up sudo ethtool -s {{ item['name'] }} speed 10000
2021-03-25 07:22:26 +00:00
{% endif %}
{% if item['force40G'] is defined and item['force40G']|lower == "true" %}
2020-07-30 07:34:46 +00:00
#Force speed to 40G
pre-up sudo ethtool -s {{ item['name'] }} autoneg off
pre-up sudo ethtool -s {{ item['name'] }} speed 40000
2021-03-25 07:22:26 +00:00
{% endif %}
{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %}
2020-07-30 07:34:46 +00:00
#Auto speed
pre-up sudo /bin/ip link set down {{ item['name'] }} && sleep 1
pre-up sudo ethtool -s {{ item['name'] }} speed 40000 duplex full autoneg on
post-up sudo /bin/ip link set up {{ item['name'] }}
2021-03-25 07:22:26 +00:00
{% endif %}
{% if item['routes'] is defined %}
{% for route in item['routes'] %}
2021-04-23 14:09:39 +00:00
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
2021-03-25 07:22:26 +00:00
{% endfor %}
{% endif %}
{% endfor %}
2020-07-30 07:34:46 +00:00
{% endif %}
{% if addressed_interfaces is defined and addressed_interfaces != [] %}
{% for item in addressed_interfaces %}
auto {{ item['name'] }}
allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet static
address {{item['ip_address']}}/{{item['ip_netmask']}}
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
{% if item['ip_gateway'] is defined %}
gateway {{item['ip_gateway']}}
{% endif %}
{% if item['force10G'] is defined and item['force10G']|lower == "true" %}
post-up sudo ethtool -s {{ item['name'] }} autoneg off
post-up sudo ethtool -s {{ item['name'] }} speed 10000
{% endif %}
2021-03-25 07:22:26 +00:00
{% if item['routes'] is defined %}
{% for route in item['routes'] %}
2021-04-23 14:09:39 +00:00
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
2021-03-25 07:22:26 +00:00
{% endfor %}
{% endif %}
2020-07-30 07:34:46 +00:00
{% endfor %}
{% endif %}
{% if bond_interfaces is defined and bond_interfaces != [] %}
{% for item in bond_interfaces %}
{% for slave in item['slaves'] %}
auto {{slave['name']}}
iface {{slave['name']}} inet manual
bond-master {{ item['name'] }}
{% endfor %}
auto {{ item['name'] }}
{% if item['ip_address'] is defined %}
iface {{ item['name'] }} inet static
address {{item['ip_address']}}/{{item['ip_netmask']}}
{% else %}
iface {{ item['name'] }} inet manual
{% endif %}
{% if item['ip_gateway'] is defined %}
gateway {{item['ip_gateway']}}
{% endif %}
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
2022-06-27 13:22:24 +00:00
{% if item['bond-mode'] is defined %}
bond-mode {{ item['bond-mode'] }}
{% else %}
bond-mode active-backup
{% endif %}
2020-07-30 07:34:46 +00:00
bond-miimon 100
bond-slaves none
2021-03-25 07:22:26 +00:00
{% if item['routes'] is defined %}
{% for route in item['routes'] %}
2021-04-23 14:09:39 +00:00
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
2021-03-25 07:22:26 +00:00
{% endfor %}
{% endif %}
2020-07-30 07:34:46 +00:00
{% endfor %}
{% endif %}
{% if vlan_interfaces is defined and vlan_interfaces != [] %}
{% for item in vlan_interfaces %}
auto {{ item['name'] }}
{% if item['ip_address'] is defined %}
iface {{ item['name'] }} inet static
address {{item['ip_address']}}/{{item['ip_netmask']}}
{% else %}
iface {{ item['name'] }} inet manual
{% endif %}
{% if item['ip_gateway'] is defined %}
gateway {{item['ip_gateway']}}
{% endif %}
{% if item['mtu'] is defined %}
mtu {{ item['mtu'] }}
{% endif %}
vlan-raw-device {{ item['vlan-raw-device'] }}
2021-03-25 07:22:26 +00:00
{% if item['routes'] is defined %}
{% for route in item['routes'] %}
2021-04-23 14:09:39 +00:00
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
2021-03-25 07:22:26 +00:00
{% endfor %}
{% endif %}
2020-07-30 07:34:46 +00:00
{% endfor %}
{% endif %}
{% if unused_interfaces is defined and unused_interfaces != [] %}
{% for item in unused_interfaces %}
allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet manual
{% endfor %}
{% endif %}