96 lines
2.2 KiB
YAML
96 lines
2.2 KiB
YAML
- name: Install required system packages
|
|
apt: name={{ item }} state=present update_cache=yes
|
|
loop: [
|
|
'ifupdown',
|
|
'ifenslave',
|
|
]
|
|
tags: interfaces
|
|
when: ansible_distribution == "Ubuntu" and ansible_distribution_version != "22.04"
|
|
|
|
|
|
- name: Configure /etc/network/interfaces
|
|
template:
|
|
src: templates/interfaces.j2
|
|
dest: /etc/network/interfaces
|
|
backup: yes
|
|
tags: interfaces
|
|
|
|
- name: Remove /etc/network/interfaces.d/eth0
|
|
file:
|
|
path: /etc/network/interfaces.d/eth0
|
|
state: absent
|
|
tags: interfaces
|
|
|
|
# - 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 collected files
|
|
file:
|
|
path: "{{ item.path }}"
|
|
state: absent
|
|
with_items: "{{ collected_files.files }}"
|
|
tags: interfaces
|
|
|
|
- name: Add the bonding module
|
|
modprobe:
|
|
name: bonding
|
|
state: present
|
|
tags: interfaces
|
|
|
|
- name: Add the 8021q module
|
|
modprobe:
|
|
name: 8021q
|
|
state: present
|
|
tags: interfaces
|
|
|
|
- name: Make sure 8021q\dot1q makes it into /etc/modules for loading at boot time
|
|
lineinfile:
|
|
path: /etc/modules
|
|
state: present
|
|
line: '8021q'
|
|
tags: interfaces
|
|
|
|
- name: Make sure bonding makes it into /etc/modules for loading at boot time
|
|
lineinfile:
|
|
path: /etc/modules
|
|
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
|