Compare commits
No commits in common. "master" and "8016aec966ea46b2f442d4134a4ba0e851c5c8e9" have entirely different histories.
master
...
8016aec966
|
@ -1,2 +1,2 @@
|
||||||
# ansible-networkconfig
|
# ansible-networkconfig
|
||||||
This repo is intended to be used as an ansible role called network-config
|
This repo is intended to be used as an ansible role
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
'ifenslave',
|
'ifenslave',
|
||||||
]
|
]
|
||||||
tags: interfaces
|
tags: interfaces
|
||||||
when: ansible_distribution == "Ubuntu" and ansible_distribution_version != "22.04"
|
|
||||||
|
|
||||||
|
|
||||||
- name: Configure /etc/network/interfaces
|
- name: Configure /etc/network/interfaces
|
||||||
template:
|
template:
|
||||||
|
@ -21,37 +19,16 @@
|
||||||
state: absent
|
state: absent
|
||||||
tags: interfaces
|
tags: interfaces
|
||||||
|
|
||||||
# - name: Get directory stats
|
- name: Remove /etc/netplan/01-netcfg.yaml
|
||||||
# stat:
|
file:
|
||||||
# path: "/etc/netplan"
|
path: /etc/netplan/01-netcfg.yaml
|
||||||
# register: directory_stat
|
state: absent
|
||||||
|
|
||||||
# - 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
|
tags: interfaces
|
||||||
|
|
||||||
- name: Remove collected files
|
- name: Remove /etc/netplan/50-cloud-init.yaml
|
||||||
file:
|
file:
|
||||||
path: "{{ item.path }}"
|
path: /etc/netplan/50-cloud-init.yaml
|
||||||
state: absent
|
state: absent
|
||||||
with_items: "{{ collected_files.files }}"
|
|
||||||
tags: interfaces
|
tags: interfaces
|
||||||
|
|
||||||
- name: Add the bonding module
|
- name: Add the bonding module
|
||||||
|
@ -79,17 +56,3 @@
|
||||||
state: present
|
state: present
|
||||||
line: 'bonding'
|
line: 'bonding'
|
||||||
tags: interfaces
|
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
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ iface {{OOBNET_NIC}} inet static
|
||||||
{% 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'] }}
|
||||||
|
@ -24,28 +24,24 @@ iface {{ item['name'] }} inet static
|
||||||
{% 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" %}
|
{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %}
|
||||||
#Auto speed
|
#Auto speed
|
||||||
pre-up sudo /bin/ip link set down {{ item['name'] }} && sleep 1
|
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
|
pre-up sudo ethtool -s {{ item['name'] }} speed 40000 duplex full autoneg on
|
||||||
post-up sudo /bin/ip link set up {{ item['name'] }}
|
post-up sudo /bin/ip link set up {{ item['name'] }}
|
||||||
{% endif %}
|
|
||||||
{% if item['routes'] is defined %}
|
{% endif %}
|
||||||
{% for route in item['routes'] %}
|
{% endfor %}
|
||||||
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if addressed_interfaces is defined and addressed_interfaces != [] %}
|
{% if addressed_interfaces is defined and addressed_interfaces != [] %}
|
||||||
|
@ -65,11 +61,6 @@ iface {{ item['name'] }} inet static
|
||||||
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['routes'] is defined %}
|
|
||||||
{% for route in item['routes'] %}
|
|
||||||
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -95,19 +86,9 @@ auto {{ item['name'] }}
|
||||||
{% if item['mtu'] is defined %}
|
{% if item['mtu'] is defined %}
|
||||||
mtu {{ item['mtu'] }}
|
mtu {{ item['mtu'] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item['bond-mode'] is defined %}
|
|
||||||
bond-mode {{ item['bond-mode'] }}
|
|
||||||
{% else %}
|
|
||||||
bond-mode active-backup
|
bond-mode active-backup
|
||||||
{% endif %}
|
|
||||||
bond-miimon 100
|
bond-miimon 100
|
||||||
bond-slaves none
|
bond-slaves none
|
||||||
{% if item['routes'] is defined %}
|
|
||||||
{% for route in item['routes'] %}
|
|
||||||
up ip route add {{ route['network'] }} via {{ route['gateway'] }} || true
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
@ -129,12 +110,6 @@ iface {{ item['name'] }} inet static
|
||||||
mtu {{ item['mtu'] }}
|
mtu {{ item['mtu'] }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
vlan-raw-device {{ item['vlan-raw-device'] }}
|
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 %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue