Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
954c75e658 | ||
|
|
454f0d4655 | ||
|
|
21e54fbdf4 | ||
|
|
2b3fee1779 | ||
|
|
6acbb03400 | ||
|
|
4b351ebfec | ||
|
|
526722ed56 | ||
|
|
2f698b1304 | ||
|
|
716eb3f4d6 | ||
|
|
9c11fc7a83 | ||
|
|
ee51a45afe |
@@ -1,2 +1,2 @@
|
||||
# ansible-networkconfig
|
||||
This repo is intended to be used as an ansible role
|
||||
This repo is intended to be used as an ansible role called network-config
|
||||
|
||||
+44
-7
@@ -5,6 +5,8 @@
|
||||
'ifenslave',
|
||||
]
|
||||
tags: interfaces
|
||||
when: ansible_distribution == "Ubuntu" and ansible_distribution_version != "22.04"
|
||||
|
||||
|
||||
- name: Configure /etc/network/interfaces
|
||||
template:
|
||||
@@ -19,18 +21,39 @@
|
||||
state: absent
|
||||
tags: interfaces
|
||||
|
||||
- name: Remove /etc/netplan/01-netcfg.yaml
|
||||
file:
|
||||
path: /etc/netplan/01-netcfg.yaml
|
||||
state: absent
|
||||
# - name: Get directory stats
|
||||
# stat:
|
||||
# path: "/etc/netplan"
|
||||
# register: directory_stat
|
||||
|
||||
# - name: Delete directory
|
||||
# file:
|
||||
# path: "/etc/netplan"
|
||||
# state: absent
|
||||
|
||||
# - name: Create directory
|
||||
# file:
|
||||
# path: "/etc/netplan"
|
||||
# state: directory
|
||||
# owner: "{{ directory_stat.stat.pw_name }}"
|
||||
# group: "{{ directory_stat.stat.gr_name }}"
|
||||
# mode: "{{ directory_stat.stat.mode }}"
|
||||
- name: 'Collect files in netplan dir'
|
||||
find:
|
||||
paths: "/etc/netplan/"
|
||||
hidden: True
|
||||
recurse: True
|
||||
# file_type: any # Added in ansible 2.3
|
||||
register: collected_files
|
||||
tags: interfaces
|
||||
|
||||
- name: Remove /etc/netplan/50-cloud-init.yaml
|
||||
- name: Remove collected files
|
||||
file:
|
||||
path: /etc/netplan/50-cloud-init.yaml
|
||||
path: "{{ item.path }}"
|
||||
state: absent
|
||||
with_items: "{{ collected_files.files }}"
|
||||
tags: interfaces
|
||||
|
||||
|
||||
- name: Add the bonding module
|
||||
modprobe:
|
||||
name: bonding
|
||||
@@ -56,3 +79,17 @@
|
||||
state: present
|
||||
line: 'bonding'
|
||||
tags: interfaces
|
||||
|
||||
- name: Make sure ip-tables makes it into /etc/modules for loading at boot time
|
||||
lineinfile:
|
||||
path: /etc/modules
|
||||
state: present
|
||||
line: 'ip-tables'
|
||||
tags: interfaces
|
||||
|
||||
- name: Make sure ip6-tables makes it into /etc/modules for loading at boot time
|
||||
lineinfile:
|
||||
path: /etc/modules
|
||||
state: present
|
||||
line: 'ip6-tables'
|
||||
tags: interfaces
|
||||
|
||||
+106
-127
@@ -1,127 +1,106 @@
|
||||
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}}
|
||||
{% if OOBNET_GW is defined %}gateway {{OOBNET_GW}}{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if autobgp_interfaces is defined %}
|
||||
{% for item in autobgp_interfaces %}
|
||||
|
||||
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 %}
|
||||
{% if item['force10G'] is defined and item['force10G']|lower == "true" %}
|
||||
#Force speed to 10G
|
||||
post-up sudo ethtool -s {{ item['name'] }} autoneg off
|
||||
post-up sudo ethtool -s {{ item['name'] }} speed 10000
|
||||
{% endif %}
|
||||
{% if item['force40G'] is defined and item['force40G']|lower == "true" %}
|
||||
#Force speed to 40G
|
||||
pre-up sudo ethtool -s {{ item['name'] }} autoneg off
|
||||
pre-up sudo ethtool -s {{ item['name'] }} speed 40000
|
||||
{% 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 %}
|
||||
{% endfor %}
|
||||
{% 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 %}
|
||||
|
||||
{% 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 %}
|
||||
bond-mode active-backup
|
||||
bond-miimon 100
|
||||
bond-slaves none
|
||||
{% 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'] }}
|
||||
{% 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 %}
|
||||
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 {% if OOBNET_DHCP is defined and OOBNET_DHCP|lower == "true" %}dhcp{% else %}static
|
||||
address {{OOBNET_IP}}/{{OOBNET_Netmask}}
|
||||
{% if OOBNET_GW is defined %}gateway {{OOBNET_GW}}{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if autobgp_interfaces is defined %}
|
||||
{% for item in autobgp_interfaces %}
|
||||
|
||||
auto {{ item['name'] }}
|
||||
allow-hotplug {{ item['name'] }}
|
||||
iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}static
|
||||
address {{host_loopback_IP}}/32
|
||||
{% endif %}
|
||||
{% if item['mtu'] is defined %}
|
||||
mtu {{ item['mtu'] }}
|
||||
{% endif %}
|
||||
{% if item['force10G'] is defined and item['force10G']|lower == "true" %}
|
||||
# Force speed to 10G
|
||||
post-up sudo ethtool -s {{ item['name'] }} autoneg off
|
||||
post-up sudo ethtool -s {{ item['name'] }} speed 10000
|
||||
{% endif %}
|
||||
{% if item['force40G'] is defined and item['force40G']|lower == "true" %}
|
||||
# Force speed to 40G
|
||||
pre-up sudo ethtool -s {{ item['name'] }} autoneg off
|
||||
pre-up sudo ethtool -s {{ item['name'] }} speed 40000
|
||||
{% endif %}
|
||||
{% 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 addressed_interfaces is defined and addressed_interfaces != [] %}
|
||||
{% for item in addressed_interfaces %}
|
||||
|
||||
auto {{ item['name'] }}
|
||||
allow-hotplug {{ item['name'] }}
|
||||
iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}static
|
||||
address {{item['ip_address']}}/{{item['ip_netmask']}}
|
||||
{% endif %}
|
||||
{% if item['mtu'] is defined %}
|
||||
mtu {{ item['mtu'] }}
|
||||
{% endif %}
|
||||
{% 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 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'] }}
|
||||
iface {{ item['name'] }} inet {% if item['dhcp'] is defined and item['dhcp']|lower == "true" %}dhcp{% else %}{% if item['ip_address'] is defined %}static
|
||||
address {{item['ip_address']}}/{{item['ip_netmask']}}
|
||||
{% else %}manual{% endif %}{% endif %}
|
||||
{% 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 vlan_interfaces is defined and vlan_interfaces != [] %}
|
||||
{% for item in vlan_interfaces %}
|
||||
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
|
||||
address {{item['ip_address']}}/{{item['ip_netmask']}}
|
||||
{% else %}manual{% endif %}{% endif %}
|
||||
{% 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 %}
|
||||
|
||||
Reference in New Issue
Block a user