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,152 +1,106 @@
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
address {{host_loopback_IP}}/32 address {{host_loopback_IP}}/32
{% endif %} {% endif %}
{% 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 %}
{% for item in autobgp_interfaces %} {% if autobgp_interfaces is defined %}
{% for item in autobgp_interfaces %}
auto {{ item['name'] }}
allow-hotplug {{ item['name'] }} auto {{ item['name'] }}
iface {{ item['name'] }} inet static allow-hotplug {{ item['name'] }}
address {{host_loopback_IP}}/32 iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}static
{% if item['mtu'] is defined %} address {{host_loopback_IP}}/32
mtu {{ item['mtu'] }} {% endif %}
{% endif %} {% if item['mtu'] is defined %}
{% if item['force10G'] is defined and item['force10G']|lower == "true" %} mtu {{ item['mtu'] }}
#Force speed to 10G {% endif %}
post-up sudo ethtool -s {{ item['name'] }} autoneg off {% if item['force10G'] is defined and item['force10G']|lower == "true" %}
post-up sudo ethtool -s {{ item['name'] }} speed 10000 # Force speed to 10G
{% endif %} post-up sudo ethtool -s {{ item['name'] }} autoneg off
{% if item['force40G'] is defined and item['force40G']|lower == "true" %} post-up sudo ethtool -s {{ item['name'] }} speed 10000
#Force speed to 40G {% endif %}
pre-up sudo ethtool -s {{ item['name'] }} autoneg off {% if item['force40G'] is defined and item['force40G']|lower == "true" %}
pre-up sudo ethtool -s {{ item['name'] }} speed 40000 # Force speed to 40G
{% endif %} pre-up sudo ethtool -s {{ item['name'] }} autoneg off
{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %} pre-up sudo ethtool -s {{ item['name'] }} speed 40000
#Auto speed {% endif %}
pre-up sudo /bin/ip link set down {{ item['name'] }} && sleep 1 {% if item['routes'] is defined %}
pre-up sudo ethtool -s {{ item['name'] }} speed 40000 duplex full autoneg on {% for route in item['routes'] %}
post-up sudo /bin/ip link set up {{ item['name'] }} up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
{% endif %} {% endfor %}
{% if item['routes'] is defined %} {% endif %}
{% for route in item['routes'] %} {% endfor %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true {% endif %}
{% endfor %}
{% endif %} {% if addressed_interfaces is defined and addressed_interfaces != [] %}
{% endfor %} {% for item in addressed_interfaces %}
{% endif %}
auto {{ item['name'] }}
{% if addressed_interfaces is defined and addressed_interfaces != [] %} allow-hotplug {{ item['name'] }}
{% for item in addressed_interfaces %} iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}static
address {{item['ip_address']}}/{{item['ip_netmask']}}
auto {{ item['name'] }} {% endif %}
allow-hotplug {{ item['name'] }} {% if item['mtu'] is defined %}
iface {{ item['name'] }} inet static mtu {{ item['mtu'] }}
address {{item['ip_address']}}/{{item['ip_netmask']}} {% endif %}
{% if item['mtu'] is defined %} {% if item['routes'] is defined %}
mtu {{ item['mtu'] }} {% for route in item['routes'] %}
{% endif %} up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
{% if item['ip_gateway'] is defined %} {% endfor %}
gateway {{item['ip_gateway']}} {% endif %}
{% endif %}
{% if item['force10G'] is defined and item['force10G']|lower == "true" %} {% endfor %}
post-up sudo ethtool -s {{ item['name'] }} autoneg off {% endif %}
post-up sudo ethtool -s {{ item['name'] }} speed 10000
{% endif %} {% if bond_interfaces is defined and bond_interfaces != [] %}
{% if item['routes'] is defined %} {% for item in bond_interfaces %}
{% for route in item['routes'] %} {% for slave in item['slaves'] %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true auto {{slave['name']}}
{% endfor %} iface {{slave['name']}} inet manual
{% endif %} bond-master {{ item['name'] }}
{% endfor %}
{% endfor %}
{% endif %} auto {{ item['name'] }}
iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}{% if item['ip_address'] is defined %}static
{% if bond_interfaces is defined and bond_interfaces != [] %} address {{item['ip_address']}}/{{item['ip_netmask']}}
{% for item in bond_interfaces %} {% else %}manual{% endif %}{% endif %}
{% for slave in item['slaves'] %} {% if item['routes'] is defined %}
auto {{slave['name']}} {% for route in item['routes'] %}
iface {{slave['name']}} inet manual up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
bond-master {{ item['name'] }} {% endfor %}
{% endfor %} {% endif %}
{% endfor %}
auto {{ item['name'] }} {% endif %}
{% if item['ip_address'] is defined %}
iface {{ item['name'] }} inet static {% if vlan_interfaces is defined and vlan_interfaces != [] %}
address {{item['ip_address']}}/{{item['ip_netmask']}} {% for item in vlan_interfaces %}
{% else %} auto {{ item['name'] }}
iface {{ item['name'] }} inet manual iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}{% if item['ip_address'] is defined %}static
{% endif %} address {{item['ip_address']}}/{{item['ip_netmask']}}
{% if item['ip_gateway'] is defined %} {% else %}manual{% endif %}{% endif %}
gateway {{item['ip_gateway']}} {% if item['routes'] is defined %}
{% endif %} {% for route in item['routes'] %}
{% if item['mtu'] is defined %} up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
mtu {{ item['mtu'] }} {% endfor %}
{% endif %} {% endif %}
{% if item['bond-mode'] is defined %} {% endfor %}
bond-mode {{ item['bond-mode'] }} {% endif %}
{% else %}
bond-mode active-backup {% if unused_interfaces is defined and unused_interfaces != [] %}
{% endif %} {% for item in unused_interfaces %}
bond-miimon 100 allow-hotplug {{ item['name'] }}
bond-slaves none iface {{ item['name'] }} inet manual
{% if item['routes'] is defined %} {% endfor %}
{% for route in item['routes'] %} {% endif %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
{% endfor %}
{% endif %}
{% 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'] }}
{% if item['routes'] is defined %}
{% for route in item['routes'] %}
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
{% endfor %}
{% endif %}
{% 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 %}