Compare commits

...

1 Commits

Author SHA1 Message Date
coryHawkvelt 954c75e658 Update templates/interfaces.j2
Enable DHCP as an option
2024-11-25 12:33:40 +00:00
1 changed files with 106 additions and 152 deletions

View File

@ -1,5 +1,5 @@
auto lo auto lo
iface lo inet loopback iface lo inet loopback
{% if host_loopback_IP is defined %} {% if host_loopback_IP is defined %}
auto lo:1 auto lo:1
iface lo:1 inet static iface lo:1 inet static
@ -9,37 +9,33 @@ iface lo:1 inet static
{% if OOBNET_NIC is defined %} {% if OOBNET_NIC is defined %}
auto {{OOBNET_NIC}} auto {{OOBNET_NIC}}
allow-hotplug {{OOBNET_NIC}} allow-hotplug {{OOBNET_NIC}}
iface {{OOBNET_NIC}} inet static iface {{OOBNET_NIC}} inet {% if OOBNET_DHCP is defined and OOBNET_DHCP|lower == "true" %}dhcp{% else %}static
address {{OOBNET_IP}}/{{OOBNET_Netmask}} address {{OOBNET_IP}}/{{OOBNET_Netmask}}
{% if OOBNET_GW is defined %}gateway {{OOBNET_GW}}{% endif %} {% if OOBNET_GW is defined %}gateway {{OOBNET_GW}}{% endif %}
{% endif %} {% endif %}
{% endif %}
{% if autobgp_interfaces is defined %} {% if autobgp_interfaces is defined %}
{% for item in autobgp_interfaces %} {% for item in autobgp_interfaces %}
auto {{ item['name'] }} auto {{ item['name'] }}
allow-hotplug {{ item['name'] }} allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet static iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}static
address {{host_loopback_IP}}/32 address {{host_loopback_IP}}/32
{% endif %}
{% if item['mtu'] is defined %} {% if item['mtu'] is defined %}
mtu {{ item['mtu'] }} mtu {{ item['mtu'] }}
{% endif %} {% endif %}
{% if item['force10G'] is defined and item['force10G']|lower == "true" %} {% if item['force10G'] is defined and item['force10G']|lower == "true" %}
#Force speed to 10G # Force speed to 10G
post-up sudo ethtool -s {{ item['name'] }} autoneg off post-up sudo ethtool -s {{ item['name'] }} autoneg off
post-up sudo ethtool -s {{ item['name'] }} speed 10000 post-up sudo ethtool -s {{ item['name'] }} speed 10000
{% endif %} {% endif %}
{% if item['force40G'] is defined and item['force40G']|lower == "true" %} {% if item['force40G'] is defined and item['force40G']|lower == "true" %}
#Force speed to 40G # Force speed to 40G
pre-up sudo ethtool -s {{ item['name'] }} autoneg off pre-up sudo ethtool -s {{ item['name'] }} autoneg off
pre-up sudo ethtool -s {{ item['name'] }} speed 40000 pre-up sudo ethtool -s {{ item['name'] }} speed 40000
{% endif %} {% endif %}
{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %}
#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'] }}
{% endif %}
{% if item['routes'] is defined %} {% if item['routes'] is defined %}
{% for route in item['routes'] %} {% for route in item['routes'] %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
@ -53,18 +49,12 @@ up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
auto {{ item['name'] }} auto {{ item['name'] }}
allow-hotplug {{ item['name'] }} allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet static iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}static
address {{item['ip_address']}}/{{item['ip_netmask']}} address {{item['ip_address']}}/{{item['ip_netmask']}}
{% endif %}
{% if item['mtu'] is defined %} {% if item['mtu'] is defined %}
mtu {{ item['mtu'] }} mtu {{ item['mtu'] }}
{% endif %} {% 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 %}
{% if item['routes'] is defined %} {% if item['routes'] is defined %}
{% for route in item['routes'] %} {% for route in item['routes'] %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
@ -83,69 +73,33 @@ iface {{slave['name']}} inet manual
{% endfor %} {% endfor %}
auto {{ item['name'] }} auto {{ item['name'] }}
{% if item['ip_address'] is defined %} iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}{% if item['ip_address'] is defined %}static
iface {{ item['name'] }} inet static
address {{item['ip_address']}}/{{item['ip_netmask']}} address {{item['ip_address']}}/{{item['ip_netmask']}}
{% else %} {% else %}manual{% endif %}{% endif %}
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 %}
{% if item['bond-mode'] is defined %}
bond-mode {{ item['bond-mode'] }}
{% else %}
bond-mode active-backup
{% endif %}
bond-miimon 100
bond-slaves none
{% if item['routes'] is defined %} {% if item['routes'] is defined %}
{% for route in item['routes'] %} {% for route in item['routes'] %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if vlan_interfaces is defined and vlan_interfaces != [] %} {% if vlan_interfaces is defined and vlan_interfaces != [] %}
{% for item in vlan_interfaces %} {% for item in vlan_interfaces %}
auto {{ item['name'] }} auto {{ item['name'] }}
{% if item['ip_address'] is defined %} iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}{% if item['ip_address'] is defined %}static
iface {{ item['name'] }} inet static address {{item['ip_address']}}/{{item['ip_netmask']}}
address {{item['ip_address']}}/{{item['ip_netmask']}} {% else %}manual{% endif %}{% endif %}
{% 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'] }}
{% if item['routes'] is defined %} {% if item['routes'] is defined %}
{% for route in item['routes'] %} {% for route in item['routes'] %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if unused_interfaces is defined and unused_interfaces != [] %} {% if unused_interfaces is defined and unused_interfaces != [] %}
{% for item in unused_interfaces %} {% for item in unused_interfaces %}
allow-hotplug {{ item['name'] }} allow-hotplug {{ item['name'] }}
iface {{ item['name'] }} inet manual iface {{ item['name'] }} inet manual
{% endfor %} {% endfor %}